Hello all:
I have written a function that gets data (numbers) from a text file.
My function works by taking a line from the text file, discarding unnecessary symbols, and putting the numbers into a vector. Here's a snippet:
// Get data from text file. Values then put into one vector.
if( line == theData ){
std::getline( file, line );
line.erase(remove( line.begin(), line.end(), '\'' ), line.end() );
std::istringstream streamLine( line );
}
The problem is, the text file looks ugly. I have to put the data on a single line. There are labels on the line above. When there are many numbers, the labels and the data are wrapped around to the next lines. So it is very hard for a person using the file to tell which label goes with which number on the line below.
What I want to do is have a list (vertical) of labels with the correct numbers next to them. But I'm not sure if this would be possible. From what I have seen, it seems like data always have to be on the same line. I need a result like:
Apple: 1
Orange: 2
Banana: 3
Result vector has elements 1,2,3
Thanks for any help.