Hi all,

Given this source code:
----------------------------------------------------------------------
#include <iostream>
#include <sstream>
#include <strstream>
#include <string>

int
main()
        {
        stringstream s1;
        strstream s2;
        string s, fmt("string");

        s1 << fmt[2];
        s1 << ends;
        s = s1.str();
        cout << "s1: " << s << endl;
        cout << "s1 size: " << s.size() << endl;

        s2 << fmt[1];
        s2 << ends;
        s = s2.str();
        cout << "s2: " << s << endl;
        cout << "s2 size: " << s.size() << endl;

        return 0;
        }
----------------------------------------------------------------

The following output is generated:
$ uname -a
CYGWIN_NT-4.0 A19990524 1.3.9(0.51/3/2) 2002-01-21 12:48 i686 unknown
$ g++ -v
Reading specs from /bin/../lib/gcc-lib/i686-pc-cygwin/2.95.3-5/specs
gcc version 2.95.3-5 (cygwin special)
$ g++ tst.cc
$ ./a.exe
s1: r^@
s1 size: 2
s2: t
s2 size: 1

Note, the shell used is bash.  So the '^@' is what is printed on the
console.

My question is, why is stringstream and strstream behaving differently?
I think stringstream should behave like strstream.  Comments?

--jc
--
[EMAIL PROTECTED]     Adtech, Inc.    (808) 734-3300

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Reply via email to