i need to enter a couple of data in a file .dat and display it this is my code help please?
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
class flight{
int flightno;
char name;
public:
void input()
{
cout<<"Enter fno: ";
cin>>flightno;
cout<<"Enter name: ";
gets(name);
}
void output()
{
cout<<flightno<<" "<<name;
}
}f;
void main()
{clrscr();
flight f[3];
fstream fs("C:\\turboc3\\bin\\flight.dat", ios::app| ios::binary);
for(int i=0;i<2;i++){
fs.write((char*)&f[i],sizeof(f[i]));
f[i].input();}
fstream fs("C:\\turboc3\\bin\\flight.dat", ios::in| ios::binary);
for(int i=0;i<2;i++){
fs.read((char*)&f[i],sizeof(f[i]));
f[i].output();}
getch();}