| www.delorie.com/archives/browse.cgi | search |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
| Message-ID: | <8AC36D3167EED41184C800508BD9540502CF5D03@apollo.adtech-inc.com> |
| From: | "Ching, Jimen" <Jimen DOT Ching AT SpirentCom DOT COM> |
| To: | "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com> |
| Subject: | stringstream vs. strstream |
| Date: | Mon, 28 Jan 2002 16:08:26 -1000 |
| MIME-Version: | 1.0 |
| X-Mailer: | Internet Mail Service (5.5.2653.19) |
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 AT adtech-inc DOT 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/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |