The program should list all flight numbers that have at least one seat available. The screen display should show the flight number, departure date and time, departure airport code, arrival airport code and the number of seats available.
int main()
{
int const maxflights = 5;
struct flight
{
char flightnum[5];
char detail[14];
char departure[20];
char arrival[20];
char avail[12];
};
flight record[maxflights];
int i = 0;
int count = 0;
ifstream infile;
infile.open("flights.dat");
if(infile.fail())
cout << "File doesnt exist";
else
{
while (!infile.eof())
{
infile >> record[count].flightnum;
infile >> record[count].detail;
infile >> record[count].departure;
infile >> record[count].arrival;
infile >> record[count].avail;
infile >> ws;
count ++;
}
infile.close();
}
for (i=0;i<=count;i++)
cout << record[i].flightnum << endl;
cout << record[i].detail[14] << endl;
cout << record[i].departure << endl;
cout << record[i].arrival << endl;
cout << record[i].avail << endl;
return 0;
}
i can read the file but wen i come to display it , it doesnt display properly..... and also if i just try flightnum commands only....it displays the whole file
a sample of my .dat file
QF502
20/05/01 10:20
SYDNEY
ADELAIDE
10 E AB
15 E CDE
22 E ADF
31 E BCF
35 E ABCD
45 E AB
50 E DEF
99
atm it displays sumthin like this
QF50220/05/01
10:20 SYDNEY
ADELAIDE
10
E
15
E
CDE
etc