Tech Support > Microsoft Windows > Development Resources > C++ getline() problem with isolated 0xA (OT)
C++ getline() problem with isolated 0xA (OT)
Posted by Bruce Varley on April 5th, 2008


Hi, My ISP has just changed servers and all the C++ newsgroups are
inaccessible. I hope someone here is prepared to assist me.

I need to parse and decode fields from a CSV file. The lines are terminated
with 0D 0A, and the fields with ','. This particular file is from a
spreadsheet which contains multiple lines in some cells, which results in 0A
terminators within some fields. A typical line will look like this (hex
chars in caps):

abcde, fghij,"qwert0Ayuiop","zxcvb0Aghjkl"0D0A

I started out using getline(), and specifying a 0D terminator as the 3rd
argument. That didn't work, so I did what I've done before with getline,
that is to write my own using ifstream.get(). Unfortunately, that also seems
to have problems. The get() function reads the 0A, but seems to ignore the
0D, which is the distinguishing character at the end of the line.

How can I distinguish the real line terminator, the 0D0A combination, and
skip over the isolated 0As? TIA


Posted by Bruce Varley on April 5th, 2008



"Bruce Varley" <bxvarley@weastnet.com.au> wrote in message
news:I9ednfHagIT4PmranZ2dnUVZ_gqdnZ2d@westnet.com. au...




Similar Posts