I'm currently writing a program that deals with booking flights. I need to read in all of the flight information from a file, the information in the file is just separated by a single space.
Here's just a few lines of the file...
AA 12 BOS SAN 299.99 200
DT 908 JFK ORD 149.99 150
AA 73 LAX SAN 39.99 30
US 401 BOS SAN 314.99 100
CO 73 ORD SFO 238.99 150
CO 782 BOS SAN 309.99 250
US 770 BOS ORD 194.99 83
DT 908 JFK MIA 99.99 80
US 780 BOS ORD 194.99 83
CO 76 ORD SFO 228.99
Here's what I have for the function so far..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int readFlights(Flight flights[], ifstream & flightFile)
{
string airline, orig, dest;
int nFlights, flightNum, seats;
float price;
// TODO TODO TODO TODO
ifstream infile;
infile.open ("flights.txt");
while(!infile.eof) // To get you all the lines.
{
}
infile.close();
}
What I have to do is set the appropriate element in the array flights to the values just read from the file. How should I go about doing this?
I've done a much more basic concept of this before with a motorcycle inventory list but it doesn't seem to really help here.