将std :: string转换为basic_ostream?

时间:2010-06-24 13:59:18

标签: c++

上面有转换吗?

2 个答案:

答案 0 :(得分:10)

std::string转换为输出流?通常是:将字符串转换为输入流,该流从给定字符串中读取字符:

std::string myString = //...
std::istringstream iss(myString);

另请参阅:http://www.cplusplus.com/reference/iostream/istringstream/

答案 1 :(得分:5)

std::ostringstream来自< sstream>:

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