stringstream vs ifstream - one BIG difference

Discussion in 'C++' started by Dmitri Zhukov, May 6, 2004.

  1. 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?
     
    Dmitri Zhukov, May 6, 2004
    #1
    1. Advertising

  2. 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
     
    =?ISO-8859-15?Q?Juli=E1n?= Albo, May 6, 2004
    #2
    1. Advertising

  3. Dmitri Zhukov

    Siemel Naran Guest

    "Dmitri Zhukov" <> wrote in message
    news:c7dm4f$fut$-

    > 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.
     
    Siemel Naran, May 7, 2004
    #3
  4. Cool. Thank u.

    "Julián Albo" <> ???????/???????? ? ???????? ?????????:
    news:...
    > 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
     
    Dmitri Zhukov, May 7, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shaguf
    Replies:
    0
    Views:
    538
    Shaguf
    Dec 24, 2008
  2. Shaguf
    Replies:
    0
    Views:
    496
    Shaguf
    Dec 26, 2008
  3. dmtr
    Replies:
    8
    Views:
    3,303
    Michael Doubez
    Jul 28, 2010
  4. Shaguf
    Replies:
    0
    Views:
    269
    Shaguf
    Dec 26, 2008
  5. Shaguf
    Replies:
    0
    Views:
    244
    Shaguf
    Dec 24, 2008
Loading...

Share This Page