0% found this document useful (0 votes)
7 views2 pages

Accept Data

accept

Uploaded by

Nurlign Yitbarek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Accept Data

accept

Uploaded by

Nurlign Yitbarek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream>

#include <fstream>
#include <string>
#include <iomanip>
using namespace std;

struct Student {
int Sno;
string Student_Id;
string First_Name;
string Father_Name;
string G_Father_Name;
string Sex;
string dept;
int Mid;
int final;
string Grade;
}s;

int main()
{
//clrscr();
char filename[15];
ofstream outdata;
cout<<"\nenter file name : ";
cin>>filename;
outdata.open(filename,ios::out);
if(outdata.fail())
{
cerr<<"\nError opening "<<filename;
//getch();
//exit(1);
}
//stud_info student;
//accept data here
cout<<"\nEnter student role number : ";
cin>>s.Sno;
cout<<"\nEnter student ID : ";
cin>>s.Student_Id;
cout<<"\nEnter student Fname : ";
cin>>s.First_Name;
cout<<"\nEnter student father name : ";
cin>>s.Father_Name;
cout<<"\nEnter student G.father name : ";
cin>>s.G_Father_Name;
cout<<"\nEnter student Sex : ";
cin>>s.Sex;
cout<<"\nEnter student department : ";
cin>>s.dept;
cout<<"\nEnter student Mid(40%) : ";
cin>>s.Mid;
cout<<"\nEnter student final(60%) : ";
cin>>s.final;
//now write to the file
outdata.seekp(((s.Sno)-1) * sizeof(s));
outdata.write((char*) &s, sizeof(s));
outdata.close();
cout<<"\nData has been saved";
//getch();
}

You might also like