This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
stringstream vs. strstream
- From: "Ching, Jimen" <Jimen dot Ching at SpirentCom dot COM>
- To: "'cygwin at cygwin dot com'" <cygwin at cygwin dot com>
- Date: Mon, 28 Jan 2002 16:08:26 -1000
- Subject: stringstream vs. strstream
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
--
jching@adtech-inc.com 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/