need help !!!!!!!!!!
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 const maxflights = 5;
int i = 0;
int count = 0;
cout << "File doesnt exist";
infile >> record[count].flightnum;
infile >> record[count].detail;
infile >> record[count].departure;
infile >> record[count].arrival;
infile >> record[count].avail;
infile >> ws;
cout << record[i].flightnum << endl;
cout << record[i].detail << endl;
cout << record[i].departure << endl;
cout << record[i].arrival << endl;
cout << record[i].avail << endl;
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
10 E AB
15 E CDE
22 E ADF
31 E BCF
35 E ABCD
45 E AB
50 E DEF
atm it displays sumthin like this
The input operator is treating the whitespaces in your file as a delimiter.
Use infile.getline(char *, int array, "\n") instead of infile >> to read everything into your variable up to the newline character. That should solve your problem.
Hint* You might want to read up on random access.
If you need help with homework, do the right thing:
1) Register with the board so people know who you are
2) if you paste code into your post, then use [ code][ /code] tags so that your code is readable!
puts and gets
Perhaps if you somethin like this for input:
and for output:
infile << strupr(array[num].member) << endl;
if you want to print your information, I would suggest using puts... At least this is what has worked for me!