how to empty a stringstream?

Discussion in 'C++' started by minjie, Jul 15, 2003.

  1. minjie

    minjie Guest

    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.
     
    minjie, Jul 15, 2003
    #1
    1. Advertising

  2. "minjie" <> wrote...
    > [...]


    std::stringstream ss;
    ...
    ss.str(std::string()); // or ss.str("");
     
    Victor Bazarov, Jul 15, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John

    empty/non-empty element

    John, Jul 15, 2003, in forum: XML
    Replies:
    1
    Views:
    1,063
    Klaus Johannes Rusch
    Jul 16, 2003
  2. Lukas
    Replies:
    3
    Views:
    865
    spiff
    Nov 10, 2005
  3. Francesco

    Empty a stringstream...

    Francesco, Mar 1, 2004, in forum: C++
    Replies:
    3
    Views:
    15,567
    prakasha
    Mar 22, 2011
  4. Marcia Hon

    Check if a directory is empty and empty it

    Marcia Hon, Feb 8, 2004, in forum: C Programming
    Replies:
    8
    Views:
    611
    Dave Thompson
    Feb 14, 2004
  5. mthread

    making stringstream empty

    mthread, Feb 21, 2008, in forum: C++
    Replies:
    5
    Views:
    1,838
    Jeff Schwab
    Feb 21, 2008
Loading...

Share This Page