473,385 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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.
Jul 19 '05 #1
1 15309
"minjie" <mi****@excite.com> wrote...
[...]


std::stringstream ss;
...
ss.str(std::string()); // or ss.str("");
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Woodster | last post by:
I am using std::stringstream to format a string. How can I clear the stringstream variable I am using to "re use" the same variable? Eg: Using std::string std::string buffer; buffer =...
3
by: Mike Chirico | last post by:
Sorry about the newbie question. What's the best way to convert numbers to strings in C++. The following works, but is it better than using the sprintf() "old C" way of converting? #include...
1
by: KidLogik | last post by:
Hello! I am using std::stringstream && std::string to parse a text file -> std::ifstream in; std::string s; std::streamstring ss; int n; I grab each line like so -> std::getline(in,s);
2
by: Francesco | last post by:
Ciao, I've this problem... #include <iostream> #include <stdlib.h> #include <sstream> using namespace std; int main(int argc, char *argv) { stringstream s; s << " questa e' una prova " <<...
5
by: cherico | last post by:
I'd like to read stings from cin and put them in stringstream. I use a string object as an intermediate "container" to store data from cin and then put them in stringstream. stringstream ss ;...
5
by: William Payne | last post by:
How do you get rid the contents in a std::stringstream? I'm using one in a for loop to format some status messages which I print to the screen. The stringstream member function clear() only clears...
9
by: martinezfive | last post by:
Hi, I feel no doubt some documentation contains my answer, so bare with me. Given the following: #inclde <stdio.h> #include <sstream> void f() { std::stringstream a("Hello World!\n");
4
by: clb | last post by:
I am trying to use stringstreams and my book doesn't cover the included methods. For example, if I init a istringstream on a string and suck all the data out, then put more stuff into the string,...
5
by: mthread | last post by:
Hi, I am using a variable of type stringstream in my application. I am adding some information in the stream. I would like to know what is the method to make the stream empty. Thanx in advance.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.