Topic: Answer ostrstram question
Author: djones@megatest.com (Dave Jones)
Date: Tue, 12 Jul 1994 19:35:22 GMT Raw View
I still don't know if ostrstream *should* keep the string in a null-terminated
state. I was hoping someone familiar with the proposed standards would
comment. But for practical it does not have to keep the string nicely
terminated, (assuming the user knows that some installation might not do so),
because there is a way for the user to terminate the string "by hand".
A number of people have steered me toward the "ends" object. It is
essentially a synonymn for the null character, and is used thusly:
ostrstream ostr;
ostr << "foo" << ends;
The reason this came up is that a co-worker had been using one implementation
that did keep the string in a null-terminated state, and he assumed that that
behavior was standard. When he switched to another implementation that
just leaves the rest of the string buffer with whatever garbage it
happened to have in it initially, his code broke.