头文件
#include <sstream>
简单用法
std::stringstream ssTest;
ssTest << "welcome to https://blog.51cto.com/fengyuzaitu" << std::endl;
std::cout << ssTest.str();
高阶用法
https://blog.51cto.com/fengyuzaitu/2047650
https://blog.51cto.com/fengyuzaitu/1735334
清除内部数据
clear函数并不能清理数据
std::stringstream ssTest;
ssTest << "welcome to https://blog.51cto.com/fengyuzaitu" << std::endl;
ssTest.clear();
std::cout << ssTest.str();
必须使用str("")
std::stringstream ssTest;
ssTest << "welcome to https://blog.51cto.com/fengyuzaitu" << std::endl;
ssTest.str("");
ssTest << "welcome to https://blog.51cto.com/fengyuzaitu" << std::endl;
std::cout << ssTest.str();