stringstream

stringstream strm;创建自由的stringstream对象、

stringstream strm(s);创建存储s的副本的stringstream对象,其中s是string类型的对象

strm.str();返回strm中存储的string类型对象

strm.str(s);将string类型的s复制给strm,返回void

 
getline(cin,str)//read a line and word from input into str;
string word;
    istringstream stream( "nihao wome" );//bind to stream the “nihao”. 你好和输入流绑定        stream>> word;//read a word from stream // 把“ nihao ”写入 stream 中, word 接受空格字符前的内容 nihao 写入 word ,其他还在流中
         cout<<word;

你可能感兴趣的:(stringstream)