Re: std::ostringstream unexpected behavior with .net 2003.

Discussion in 'C++' started by Victor Bazarov, Jun 25, 2003.

  1. "Nathalie D'Amours" <> wrote...
    > I am using Microsoft VC .net 2003 and the std::eek:stringstream seams to

    behave
    > in an unexpected way.
    >
    > int i = 3;
    > std::eek:stringstream os;
    > os << i << std::ends;
    > std::string s1 = os.str();
    > std::string s2("3");
    > bool result = (s1 == s2);
    >
    > When I execute this code, 'result' gets set to false. Obviously I am
    > expecting the strings to be identical. I've stepped in the comparison

    code
    > and the internal call to ::strcmp correctly returns 0 but then there is

    some
    > logic to compare the string lengths and they differ. s1 size is 2 and s2
    > is 1 and this is why the comparison function returns false.
    >
    > This seems buggy to me. Am I missing something?


    Yes. Drop the "<< std::ends".

    > Has anyone else seen the
    > same problem?


    Probably. I haven't.
     
    Victor Bazarov, Jun 25, 2003
    #1
    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. Russell Hanneken
    Replies:
    0
    Views:
    899
    Russell Hanneken
    Jun 25, 2003
  2. Chris
    Replies:
    3
    Views:
    2,028
    Chris
    Feb 17, 2004
  3. Jason Heyes
    Replies:
    1
    Views:
    2,640
    Shezan Baig
    Feb 6, 2005
  4. Bala2508
    Replies:
    28
    Views:
    1,197
    Jim Langston
    Nov 3, 2007
  5. Pallav singh
    Replies:
    3
    Views:
    4,126
    Saeed Amrollahi
    Oct 21, 2009
Loading...

Share This Page