Article View: gnu.g++.help
Article #751ostrstream
From: Albert Golembiowski
Date: Mon, 28 Aug 1995 19:45
Date: Mon, 28 Aug 1995 19:45
34 lines
1494 bytes
1494 bytes
I found that `ostrstream buf' object must be explicitely
terminated by '\0' to hand off a char string properly.
[Q1] Is this standard, or a bug?
[Q2] Couldn't the method `buf.str()' do it for me?
I don't see much use for a char string picking up
tail-end "star dust".
This snippet demonstrates my point:
--------------------- snip -------------------------
#include <strstream.h>
template <class Type>
Str& operator < (Str& Out, Vect<Type>& V) // insert
{//__~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ostrstream buf;
V.print(buf,"","",""); // put out vector values
buf << '\0'; // why is this necessary?
char *pb = buf.str();
Out = Str(pb);
delete pb;
return Out;
}
--------------------- snip -------------------------
Thank you,
--
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Albert Golembiowski albert@inrs-telecom.uquebec.ca (514) 762-8655
INRS Telecommunications, 16 Place du Commerce, Verdun, Quebec, Canada, H3E 1H6
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Technical Details
Message-ID:
<9508281944.AA10055@vital>Path:
arc1-ca.pugleaf.net!inrs-telecom.uquebec.ca!albertShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!inrs-telecom.uquebec.ca!albert From: albert@inrs-telecom.uquebec.ca (Albert Golembiowski) Newsgroups: gnu.g++.help,comp.lang.c++ Subject: ostrstream Date: 28 Aug 1995 15:45:13 -0400 Organization: Gatewayed from the GNU Project mailing list help-g++@prep.ai.mit.edu Sender: daemon@cis.ohio-state.edu Distribution: world Message-ID: <9508281944.AA10055@vital>