C++sstream

#include 
#include
#include
#include
#include
#include
#include
#include
using namespace std;


int main()
{
	int a = 520;
	int b = 521;
	stringstream ss;
	string str;
	ss << "a= " << a << '\n';//"a= "此处有空格,字符串流是通过空格判断一个字符串的结束
	ss << "b= " << b;//  每个都输入;
	cout <<"ss="<>str;
	ss>>str;
	//会直接替换str

	//提取520 521保存为int 类型,当然c d 声明为string类型 ,那么这俩个字面常量相应的保存为string类型
	int c, d;
	string s;
	ss >> s >> c >> s >> d;
	cout << c << "  " << d << endl;
	ss.str(" ");
	cout << "SS="<

https://jingyan.baidu.com/article/d3b74d643657d61f77e6092e.html
https://blog.csdn.net/Wchenchen0/article/details/81356489#commentBox

你可能感兴趣的:(CCF2,STL学习,算法,C++,蓝桥杯)