Article View: gnu.g++.help
Article #752Re: ostrstream
From: Peter Berdeklis
Date: Tue, 29 Aug 1995 03:06
Date: Tue, 29 Aug 1995 03:06
36 lines
1266 bytes
1266 bytes
According to Albert Golembiowski <albert@inrs-telecom.uquebec.ca>:
>
> 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?
Standard.
> [Q2] Couldn't the method `buf.str()' do it for me?
How would it figure out where you wanted to end the string?
>
> I don't see much use for a char string picking up
> tail-end "star dust".
Consider this snippet:
{
ostream buf;
buf << "Start the string...";
do_some_cool_stuff();
buf << "Continue the string...";
do_some_boring_stuff();
buf << "End the string." << ends;
}
Consider the extra housekeeping required if << added a NULL at the
end of each insertion. Very slow. Better to ask the smart programmer.
;-)
Pete
Technical Details
Message-ID:
<DE1xy6.EyI@info.physics.utoronto.ca>Path:
arc1-ca.pugleaf.net!info.physics.utoronto.ca!peterReferences:
<9508281944.AA10055@vital>Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.help,comp.lang.c++ Path: arc1-ca.pugleaf.net!info.physics.utoronto.ca!peter From: peter@chinook.physics.utoronto.ca (Peter Berdeklis) Subject: Re: ostrstream Message-ID: <DE1xy6.EyI@info.physics.utoronto.ca> Nntp-Posting-Host: chinook.physics.utoronto.ca Sender: news@info.physics.utoronto.ca (System Administrator) Organization: Atmospheric Physics, University of Toronto Date: Tue, 29 Aug 1995 03:06:06 GMT References: <9508281944.AA10055@vital>