| re: ostringstream
"bml" <lee4rai@yahoo.com> wrote in message
news:D0hTb.44905$6O4.1316023@bgtnsc04-news.ops.worldnet.att.net...[color=blue]
> For the code below:
>
> ostringstream oss;
> oss << "A string using ostreamstring" << endl;
> oss.str("");
> oss.clear();
>
> "'endl' adds a newline character to and flushes the stream of oss."
> What does it mean by "flushes the stream"?[/color]
It means nothing, ostringstream's do not flush.
[color=blue]
>
> Is there any difference to clear a string content of oss by oss.str("")[/color]
and[color=blue]
> by oss.clear()?[/color]
oss.clear() does not clear a string content, so yes there is a difference!
clear(), clears the error state of a stream, it has nothing to do with
content. RTFM I think.
[color=blue]
>
> How to remove first 10 bytes from the oss, for the above example, causing
> the string content of oss to be "sing ostreamstring"?[/color]
That cannot be done, any more than you can remove the first 10 bytes from a
file. If you really need this then
1) get the string from the stringstream
2) remove the first 10 bytes from the string
3) put the string back in the stringstream
[color=blue]
>
> How to find the position of "using" inside oss? Say, "using" has a byte
> position of 9 for example.[/color]
Again this sounds like a string operation. Seems you are using stringstreams
when you should be using strings.
[color=blue]
>
> Thanks a lot!
>
>[/color]
John |