c++简单函数使用备忘

istringstream的使用

istringstream对象可以绑定一行字符串,然后以空格为分隔符把该行分隔开来。

#include<iostream>
#include<sstream>
using namespace std;

int istringstreamUse()
{
	string line;
	string outLine;
	while(getline(cin,line))
	{
		istringstream deal(line);

		while(deal>>outLine)
			cout<<outLine<<endl;
	}
	return 1;
}

int main()
{
 cout<<"experiment"<<endl;
 istringstreamUse();
 system("pause");
 return 1;
}


你可能感兴趣的:(c++简单函数使用备忘)