C++-istreamstring-分割字符串string的一个类

头文件

#include

使用方法-使用istringstream分割string默认以空格作为分隔符

#include 
#include 
#include 
using namespace std;

int main()
{
	string str = "1      2 3 4      5";
	
	istringstream tmp(str);
	while (tmp >> str)
	{
		cout << str << endl;
	}
	cout << str;
}

 

你可能感兴趣的:(C++,算法)