please tell me whats wrong with the program.
i want to write a program to create datafile containing objects using datafile handling
class student
{
int idno;
int clas;
int rno;
char name[25];
public:
void entry ()
{
cout%26lt;%26lt;"IDNO:";
cin%26gt;%26gt;idno;
cin%26gt;%26gt;clas;
cin%26gt;%26gt;rno;
gets(name);
}
void display()
{
cout%26lt;%26lt;" id number"%26lt;%26lt;idno;
}
void objs();
void readobj();
}obj;
void student:: objs(void)
{
fstream fout ( "student.dat" , ios::app|ios::binary);
student stud;
stud. entry();
fout.write((char *)%26amp;stud, sizeof(student));
fout.close();
}
void student :: readobj()
{
ifstream fin;
fin.open("student.dat");
while(fin)
{
fin.read((char*)%26amp;obj, sizeof(student));
cout%26lt;%26lt;obj.idno;
}
fin.close();
};
void main()
{
clrscr();
objs();
readobj();
}
C++. datafile containing objects?
what is the error that ur compiler shows??
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment