473,324 Members | 2,313 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,324 software developers and data experts.

stringstream to and from


Hi

is this done correctly? if not, how can it be done please?
put what ever data in a stringstream then put that in a string
and deal with it as a string.
thaks

stringstream oss; string f;
oss << vec[8] << " "
<< var1 << " this is nice " << var_n << " " << endl;
oss >f;
now if should be a long string contains all the pieces above?!

thanks
Feb 14 '07 #1
3 1606
Gary Wessle wrote:
Hi

is this done correctly? if not, how can it be done please?
put what ever data in a stringstream then put that in a string
and deal with it as a string.
thaks

stringstream oss; string f;
oss << vec[8] << " "
<< var1 << " this is nice " << var_n << " " << endl;
oss >f;
f will contain the first word output to oss. Try oss.str().

--
Ian Collins.
Feb 14 '07 #2
Ian Collins <ia******@hotmail.comwrites:
Gary Wessle wrote:
Hi

is this done correctly? if not, how can it be done please?
put what ever data in a stringstream then put that in a string
and deal with it as a string.
thaks

stringstream oss; string f;
oss << vec[8] << " "
<< var1 << " this is nice " << var_n << " " << endl;
oss >f;
f will contain the first word output to oss. Try oss.str().

--
Ian Collins.
oss.str() >f;
error: no match for ¡Æoperator>>¡Ç in
¡Æstd::basic_stringstream<_CharT,
_Traits, _Alloc>::str() const [with _CharT = char, _Traits =
std::char_traits<char>, _Alloc = std::allocator<char>]() >f¡Ç
Feb 14 '07 #3
Gary Wessle wrote:
Ian Collins <ia******@hotmail.comwrites:

>>Gary Wessle wrote:
>>>Hi

is this done correctly? if not, how can it be done please?
put what ever data in a stringstream then put that in a string
and deal with it as a string.
thaks

stringstream oss; string f;
oss << vec[8] << " "
<< var1 << " this is nice " << var_n << " " << endl;
oss >f;

f will contain the first word output to oss. Try oss.str().
Please trim signatures.
>
oss.str() >f;
error: no match for ¡Æoperator>>¡Ç in
¡Æstd::basic_stringstream<_CharT,
_Traits, _Alloc>::str() const [with _CharT = char, _Traits =
std::char_traits<char>, _Alloc = std::allocator<char>]() >f¡Ç
f = oss.str();

--
Ian Collins.
Feb 14 '07 #4

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

Similar topics

2
by: Bill Beacom | last post by:
Hi all, I am trying to use stringstream to assemble a text message from a set of user-defined objects that have the insertion operator overloaded. It seems to be putting them into the...
4
by: David Johnstone | last post by:
Hi Group, I am using gcc 3.2.2 on linux 2.4.19-4GB (SuSe 8.2). I have a situation where I need to tie an ostringstream to an istringstream so I can write to one and read back what I wrote...
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 =...
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...
10
by: vigacmoe | last post by:
I was trying to cast some strings to integers with stringstream, then this strange problem poped up. Here is my test code: stringstream conv; string from; int to; from = "1"; conv << from;
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");
7
by: Ziyan | last post by:
I am writing a C/C++ program that runs in background (Linux). Therefore, normally no output would be written into standard output. However, sometimes I want to have debug message collected and sent...
4
by: mthread | last post by:
Hi, I am using a string variable in which I do lot of appending. The only difficulty I am facing as of now is appending a integer/float value to this variable. Although I can accomplish this task...
3
by: Rune Allnor | last post by:
Hi all. I am trying to use std::stringstream to validate input from a file. The strategy is to read a line from the file into a std::string and feed this std::string to an object which breaks it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.