1. 程式人生 > >std::ostringstream 轉std::string

std::ostringstream 轉std::string

blog 獲取 con 傳遞 reference 寫入 oss href plus

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