Velocity Reviews

Velocity Reviews (
-   C++ (
-   -   how to empty a stringstream? (

minjie 07-15-2003 07:57 PM

how to empty a stringstream?
I'm writing an app that fetches a row of data from the database, and
extract the value from each column (of that row of data), and insert
each value into a linked list for later display on the GUI. Since the
values are of different data types, I'm using stringstream (say, ss)
to hold the data and converts each one into string when inserting into
the linked list. The problem is, I cannot find a method that can empty
ss before inserting another value, so I ended up with all the values
connected together in ss. For example, if column 0 has value a, column
1 has value b, column 2 has value c, ..., the linked list would end up
containing the values as follows:

node_1's value: a
node_2's value: ab
node_3's value: abc
instead of
node_1's value: a
node_2's value: b
node_3's value: c

Any suggestions?
Thanks in advance for any help.

Victor Bazarov 07-15-2003 08:02 PM

Re: how to empty a stringstream?
"minjie" <> wrote...
> [...]

std::stringstream ss;
ss.str(std::string()); // or ss.str("");

All times are GMT. The time now is 06:11 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.