iostream hierarchy istringstream:: str |
cplusplus.com |
Get/set the associated string object.
The first syntax returns a copy of the string object currently associated with the
internal buffer.
The second syntax sets a new value for the string object associated with
the buffer.
The buffer of a stringstream is usually associated with an STL
string object.
Parameters.
Return Value.
The second syntax returns a copy of the string object
currently associated with the stream's buffer.
Example.
// istringstream::str
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main () {
int val,n;
istringstream iss;
string strvalues = "32 240 2 1450";
iss.str (strvalues);
for (n=0; n<4; n++)
{
iss >> val;
cout << val+1 << endl;
}
return 0;
}
This example uses str member to associate the istringstream object with strvalues string
object.
Basic template member declaration ( basic_istringstream<charT,traits,Allocator> ):
basic_string<charT,traits,Allocator> str () const; void str (const basic_string<charT,traits,Allocator> & s ); |
See also.
(constructor)
istringstream class