stringstream vs ifstream - one BIG difference

D

Dmitri Zhukov

Hi all,

I've found out a difference between stringstream and ifstream objects:

stringstream::getline() will include \r (13) character
ifstream::getline won't include \r

I wonder how come. Is it prescribed behavior?
 
?

=?ISO-8859-15?Q?Juli=E1n?= Albo

Dmitri said:
I've found out a difference between stringstream and ifstream objects:

stringstream::getline() will include \r (13) character
ifstream::getline won't include \r

fstream objects when not in binary mode does translation of line ending
conventions of the operating system. Other streams don't do that.
 
S

Siemel Naran

stringstream::getline() will include \r (13) character
ifstream::getline won't include \r

Did you open your ifstream in ios::binary mode. If so, then I think it
should also contain the \r. Now I haven't tried this, so someone please
correct me if I am wrong. Thanks.
 
D

Dmitri Zhukov

Cool. Thank u.

Julián Albo said:
fstream objects when not in binary mode does translation of line ending
conventions of the operating system. Other streams don't do that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top