This topic has always confused me, and I think it's because I've used its functions without fully understanding how the input/output pointers really work.
Anyways, I have a text file with various words in the following format:
dog cat # bird # shoe giraffe kitten #
I would like to read the words into a string variable, separated by '#'. This is part of a function that will return true if a word was placed into the variable, or false if the next character was '#'.
1 2 3 4
|
bool readMultiWord(string & s, ifstream & infile, const string & sep)
{
}
|
In the first instance, it would store "dog cat" into s, return true. The next time the function is called, it will read the "#" and return false. Then it will be called again, store "bird" into the variable, and return true, etc.
Any help would be appreciated!