相关疑难解决方法(0)

重置字符串流

如何将字符串流的状态"重置"为创建它时的状态?

int firstValue = 1;
int secondValue = 2;

std::wstringstream ss;

ss << "Hello: " << firstValue;

std::wstring firstText(ss.str());

//print the value of firstText here


//How do I "reset" the stringstream here?
//I would like it behave as if I had created
// stringstream ss2 and used it below.


ss << "Bye: " << secondValue;

std::wstring secondText(ss.str());

//print the value of secondText here
Run Code Online (Sandbox Code Playgroud)

c++ string stringstream

77
推荐指数
3
解决办法
5万
查看次数

标签 统计

c++ ×1

string ×1

stringstream ×1