Inventory: Reading in From a File

I'm writing a program that needs to read in from a file and then use the information to create a new car (from the car class that has already been written) and increase the balance of the dealership by the amount posted at the top of the file.

The file has this format:
double (needs to be added to the balance of the dealership)
name color price
name color price

and so on for each car in the file where name and color are strings and price is a double.

Right the program will prompt the user for a file name they wish to open and then nothing will happen whatsoever. The program will continue to run but nothing will happen.

Here's my code for this option:

ifstream inFile;
string fileName;

cout << "File name: ";
cin >> fileName;
cout << endl;;

double fileBalance;

inFile >> fileBalance;

balance = balance + fileBalance;

string name_in, color_in;
double price_in;

inFile >> name_in >> color_in >> price_in;

inventory.push_back(Car(name_in, color_in, price_in));


I've dealt with file I/O streams before, but never with more than one piece of information on a line. Am I doing something terribly wrong?
Topic archived. No new replies allowed.