[Assorted-commits] SF.net SVN: assorted:[1367] sandbox/trunk/src/cc/stringstream.cc
Brought to you by:
yangzhang
From: <yan...@us...> - 2009-05-05 20:11:24
|
Revision: 1367 http://assorted.svn.sourceforge.net/assorted/?rev=1367&view=rev Author: yangzhang Date: 2009-05-05 20:11:12 +0000 (Tue, 05 May 2009) Log Message: ----------- added demo of stringstream tediousness Added Paths: ----------- sandbox/trunk/src/cc/stringstream.cc Added: sandbox/trunk/src/cc/stringstream.cc =================================================================== --- sandbox/trunk/src/cc/stringstream.cc (rev 0) +++ sandbox/trunk/src/cc/stringstream.cc 2009-05-05 20:11:12 UTC (rev 1367) @@ -0,0 +1,18 @@ +// Demo that stringstreams are tedious to use. + +#include <sstream> +#include <iostream> +using namespace std; + +int main() { + // Doesn't work: + // struct basic_ostream<char, char_traits<char> >’ has no member named ‘str’ + // cout << (stringstream() << 3).str() << endl; + + // Proper way: + stringstream ss; + ss << 3; + cout << ss.str() << endl; + + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |