#include<fstream.h>
#include<conio.h>
class student
{
int rno;
char name[10];
int total;
public:void getdata()
{
cout<<"\n Enter the regno,name and total marks : ";
cin>>rno>>name>>total;
}
void display()
{
cout<<"\n Register no :"<<rno;
cout<<"\n Name :"<<name;
cout<<"\n Total marks :"<<total;
}
};
void main()
{
clrscr();
student s;
s.getdata();
ofstream outfile("stud.dat");
outfile.write((char *)&s,sizeof(s));
ifstream infile("stud.dat");
infile.read((char *)&s,sizeof(s));
s.display();
getch();
}
#include<conio.h>
class student
{
int rno;
char name[10];
int total;
public:void getdata()
{
cout<<"\n Enter the regno,name and total marks : ";
cin>>rno>>name>>total;
}
void display()
{
cout<<"\n Register no :"<<rno;
cout<<"\n Name :"<<name;
cout<<"\n Total marks :"<<total;
}
};
void main()
{
clrscr();
student s;
s.getdata();
ofstream outfile("stud.dat");
outfile.write((char *)&s,sizeof(s));
ifstream infile("stud.dat");
infile.read((char *)&s,sizeof(s));
s.display();
getch();
}
No comments:
Post a Comment