Just something I dont understand...Lets say you had the follwing data in a file:
cat and mouse
dog and flea
fish and bait
bird and worm
if I read in the file as
it doesnt work. But if I write the last line as
while (in.getline (str1, MAX,'\n'))
in >> ws;
in.getline( str2, MAX,'\n');
in >> ws >> id >> ws >> ws;
everything is fine. Why is that? There are 2 enter's before the next block of data.
in >> ws >> id >> ws;
One solution is std::getline().
while (std::getline(cin, sInput))
I believe ws takes in all the whitespaces before the next character/until EOF, so therefore, after the first ws executes, there's nothing left for teh second ws to get rid of...