ostringstream 的清空数据方法

关于C++中 中ostringstream的清空方法。

 

ostringstream outString;
outString.str("");//清空数据

 

   容易混淆的是,outString.clear()//清空错误的标志位

 

   outString.str()有种两种用法,Get/set the associated string object (public member function)

 

 1、string str ( ) const;//获取当前字符串

 2、void str ( const string & s );//设置当前数据流为该字符串s

 

The first version returns a copy of the string object currently associated with the string stream buffer.

The second syntax copies the content of string s to the string object associated with the string stream buffer. The function effectivelly calls rdbuf()->str().

你可能感兴趣的:(C/C++)