[plain]
C++中的字符串流對象主要用處在於對多種數據類型的轉換,用法如下:
[cpp]
[cpp] view plaincopyprint?#inlcude<sstream>
using namespace std;
int main( void )
{
string s="carea 89 男";
istringstream sin(s);
string name;
int age;
string sex;
sin>>name>>age>>sex;
cout<<"姓名:"<<name<<endl
<<"年齡:"<<age<<endl
<<"性別:"<<sex<<endl;
return 0;
}