std::ostringstream 转std::string

Posted scotth

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了std::ostringstream 转std::string相关的知识,希望对你有一定的参考价值。

https://blog.csdn.net/qq1987924/article/details/7671154

http://www.cplusplus.com/reference/sstream/ostringstream/

template<class T>

void to_string(string & result,const T& t)

{

ostringstream oss;//创建一个流

oss<<t;//把值传递如流中

result=oss.str();//获取转换后的字符转并将其写入result
}
std::ostringstream os;
BigInt c;
os << c;
std::string str = os.str();

以上是关于std::ostringstream 转std::string的主要内容,如果未能解决你的问题,请参考以下文章