Tricky problem about getline() function

Hey guys, I have a tricky problem about getlien() function. I tried to use getline() to reading a whole line from a .txt file, but the returned string is only half of the original string.

Original string is: Townsville| eggs| 2.5| tomato| 4| chicken| 5 (P.S. the "|" is the delimiter)

My program is like:
string location;
string rest;

getline(fin, location, '|');
cout << location <<endl;
getline(fin, rest);
cout << rest <<endl;

...
...

It's supposed to be displayed like:
Townsville
cheese fries| 2.5| tomato sauce| 4| chicken wings| 5

But now, I get something like:
Townsville
cheese fries| 2.5| tomato sauce

The other half part of string is missing.

I can't figure out the way to solve the problem, hope u guys can help me.

Thanks a lot.
Is there a new line where it gets cut off? Otherwise I'm stumped.
No,there's no new line character, this is also my first time to have this kind of problem...
try

getline(fin, rest, '\n');
The getline function can be used to read multiline strings by supplying it with a third argument, as xivdeusxiv suggested.
Topic archived. No new replies allowed.