how to empty a stringstream?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • minjie

    how to empty a stringstream?

    Hi,
    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

    #2
    Re: how to empty a stringstream?

    "minjie" <minjie@excite. com> wrote...[color=blue]
    > [...][/color]

    std::stringstre am ss;
    ...
    ss.str(std::str ing()); // or ss.str("");


    Comment

    Working...