TITLE: inserting '\0' into ostrstream (Newsgroup: comp.lang.c++.moderated, 16 Jun 2000) CLAMAGE: Steve Clamage > >|> When you write to a stream, you never get a default null terminator, >|> because the only time you would want one is the special case of >|> treating the output stream as a C-style string. In that case, you >|> can add a null when you want one. Example: >|> mystream << ends; //predefined manipulator to end the string KANZE: kanze@gabi-soft.de >It's really irrelevant today, but I've often wondered why >ostrstream::str() didn't append the '\0'. CLAMAGE: Stephen Clamage I always assumed it was because there might not be room for the null. Then you have the problem of specifying suitable behavior. Add a null if it will fit, otherwise don't add it? And what about an expandable buffer that runs out of memory when you try to add the null? And suppose you call str() at intermediate points during building up the buffer? You presumably don't want extra nulls in there. These problems are not insoluble, but I think the rule that you get a null only when you ask for it made sense for strstreams. The str() function just returns a pointer; it doesn't modify the stream. _______________________________________________ cpptips mailing list http://cpptips.hyperformix.com