#include
#include
#include
int const max =100;
struct student_info
{
char name[20];
long int rn;
char sex;
int age;
};
void main()
{
student_info obj1[30];
int n,i;
fstream infile;
clrscr();
char fname[20];
cout<>fname;
infile.open(fname,ios::in||ios::out);
cout<>n;
cout<<"nenter the following information n";
for(i=0;i<=n-1;++i)
{
cout<>obj1[i].name;
cout<>obj1[i].rn;
cout<>obj1[i].sex;
cout<>obj1[i].age;
}
cout<<" nstoring onto the file ……………………n";
infile.open(fname,ios::out);
for(i=0;i<=n-1;i++)
{
infile<<obj1[i].name<<" "<<obj1[i].rn<<" "<<obj1[i].sex<<" "<<obj1[i].age<<endl;
}
infile.close();
infile.open(fname,ios::in);
char ch;
cout<<"n Reading from the file ………………….n";
while(!infile.eof())
{
ch=(char)infile.get();
cout<<ch;
}
cout<<"n Records from file :n";
for(i=0;i<=n-1;i++)
{
cout<<"n"<<obj1[i].name<<" "<<obj1[i].rn<<" "<<obj1[i].sex<<" "<<obj1[i].age<<endl;
}
infile.close();
getch();
}