"s" <(E-Mail Removed)> wrote...
> I using this function to read in lines from a text file. The file is
> delimited by CR/LF. The buffer that get copied contains a LF at the end
> of the string. It looks like getline is discarding the CR but not the
> LF. Is there anyway to get it to discard both the CR/LF? I'm using
> linux OS.
I think you got it wrong. std::getline puts everything, but discards
the line delimiter. If you didn't change it, the delimiter is \n (or
LF as you know it). What you get is the CR (\r) in your string. You
just need to remove it:
if (line[line.length()-1] == '\r') // there is a \r in my line!
line.erase(line.length()-1); // throw it away