The string stream is defined in the header file <sstream>;
Can be like the standard input and output stream, automatic discriminant data type output, encountered a space to stop;
Definition: StringStream SS;//defines a string stream that can be input or output;
ss<< "Carea M 65.3"; Initialize the data inside the stream,
String name;
int age;
char sex;
float weight;
ss>>name>>age>>sex>>weight; Output the data in the stream to the variable;
cout<< "Name:" <<name<<endl
<< "Age:" <<age<<endl
<< "Gender:" <<sex<<endl
<< "Weight:" <<weight<<endl;
********************************
You can also define an input stream individually (in fact, an output stream, which outputs data from a string string to a variable in a different data type;)
String s= "Hello world!";
String A;
Istringstream sin (s); Using S to initialize the input stream, the current content in S is present in the stream;
sin>>a;//Output "Hello" to A;
That's it.
string stream;