stringstream to and from

G

Gary Wessle

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
 
I

Ian Collins

Gary said:
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().
 
G

Gary Wessle

Ian Collins said:
Gary said:
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().

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¡Ç
 
I

Ian Collins

Gary said:
Gary said:
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();
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top