Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > stringstream to and from

Reply
Thread Tools

stringstream to and from

 
 
Gary Wessle
Guest
Posts: n/a
 
      02-14-2007

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
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      02-14-2007
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.
 
Reply With Quote
 
 
 
 
Gary Wessle
Guest
Posts: n/a
 
      02-14-2007
Ian Collins <(E-Mail Removed)> writes:

> 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°«
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      02-14-2007
Gary Wessle wrote:
> Ian Collins <(E-Mail Removed)> writes:
>
>
>>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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
codecvt and stringstream FabioAng C++ 1 08-08-2006 02:56 PM
stringstream and dll blackstreetcat@hotmail.com C++ 2 05-17-2006 04:46 PM
minor confusion - std::stringstream and operator (>>/<<) ma740988 C++ 5 03-27-2006 09:01 PM
std::stringstream and floating point accuracy Mr Fish C++ 5 10-21-2005 08:31 AM
Xerces, howto parse stringstream and validate with xsd-file heiko C++ 0 10-01-2005 01:06 PM



Advertisments