displaying file the same way it was made?

Apr 18, 2014 at 7:53pm
If I create a file that looks like this for example,
car 2 4 6 8
truck 1 2 3 4 5 6
plane 4 5 6 7 9

Whenever I go to open it back up like this,
ifstream inputFile;
string line;

inputFile.open("file.txt");
while (inputFile>>line)
{
cout << line << endl;
}
inputFile.close();
return 0;
}

It displays output like this,
car
2
4
6
8

How can I get it to display like above?
Apr 18, 2014 at 8:01pm
1
2
while( std::getline(inputFile, line) )
//... 
Apr 18, 2014 at 8:30pm
Thanks! That worked
Topic archived. No new replies allowed.