Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > stringstream vs ifstream - one BIG difference

Reply
Thread Tools

stringstream vs ifstream - one BIG difference

 
 
Dmitri Zhukov
Guest
Posts: n/a
 
      05-06-2004
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?


 
Reply With Quote
 
 
 
 
=?ISO-8859-15?Q?Juli=E1n?= Albo
Guest
Posts: n/a
 
      05-06-2004
Dmitri Zhukov wrote:

> 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.

--
Salu2
 
Reply With Quote
 
 
 
 
Siemel Naran
Guest
Posts: n/a
 
      05-07-2004
"Dmitri Zhukov" <(E-Mail Removed)> wrote in message
news:c7dm4f$fut$(E-Mail Removed)-

> 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.


 
Reply With Quote
 
Dmitri Zhukov
Guest
Posts: n/a
 
      05-07-2004

Cool. Thank u.

"Julián Albo" <(E-Mail Removed)> ???????/???????? ? ???????? ?????????:
news:(E-Mail Removed)...
> Dmitri Zhukov wrote:
>
> > 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.
>
> --
> Salu2



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to write a std::stringstream one-liner ? dmtr C++ 8 07-28-2010 07:24 AM
GIDS 2009 .Net:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf ASP .Net 0 12-26-2008 09:29 AM
GIDS 2009 .Net:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf ASP .Net Web Controls 0 12-26-2008 06:11 AM
GIDS 2009 Java:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf Python 0 12-24-2008 07:35 AM
GIDS 2009 Java:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf Ruby 0 12-24-2008 05:07 AM



Advertisments