I trying to write a program that uses a getline to read from a txt file.
I need it to read from the file until it reaches a line that has "$$$" in it.
I can get it to read in the file like this no problem.
//assuming all variables have been declared
while(inFile.peek() != '\r' && inFile.peek() != '\n')
{
/* gets the next line and sets it as the bike */
getline(inFile, line);
buffer << line;
buffer >> bike;
buffer.clear();
/* gets the next line and sets it as the car */
getline(inFile, line);
buffer << line;
buffer >> car;
buffer.clear();
/* gets the first line and sets it as the jeep */
getline(inFile, line);
buffer << line;
buffer >>jeep;
buffer.clear();
if(inFile.eof()) break;
}
My data file looks like this:
huffy
corvette
jeep
$$$
dog
cat
I want it to break from the while loop when it reaches the "$$$".
I have a particular function that I will perform on the
"huffy corvette jeep" values, then I want it to stop reading the values when the "$$$" is found, so I can read in the " dog cat" in the same way, but use a different function on them.
any thought??