C++ C++;将格式化字符串转换为流

C++ C++;将格式化字符串转换为流,c++,stream,printf,C++,Stream,Printf,我使用VS2008 C++。 P>正如我所理解的,在C++流中没有这样的方法:(不使用外部库)< /P> 我知道这很愚蠢,但有没有更好的方法; std::ostringstream oss; oss << "number " << i; call_some_func_with_string(oss.str()); ossstd::ostringstream oss; oss你有试过吗 inti=3; 你有没有试过 inti=3; std::cout试试这个: #inc

我使用VS2008 C++。 <> P>正如我所理解的,在C++流中没有这样的方法:(不使用外部库)< /P> 我知道这很愚蠢,但有没有更好的方法;
std::ostringstream oss;
oss << "number " << i;
call_some_func_with_string(oss.str());
oss
std::ostringstream oss;
oss你有试过吗

inti=3;
你有没有试过

inti=3;
std::cout试试这个:

#include <sstream>
// [...]
std::ostringstream buffer;
int i = 5;
buffer << "number " << i;
std::string thestring = buffer.str(); // this is the droid you are looking for
#包括
// [...]
std::ostringstream缓冲区;
int i=5;
缓冲区试试这个:

#include <sstream>
// [...]
std::ostringstream buffer;
int i = 5;
buffer << "number " << i;
std::string thestring = buffer.str(); // this is the droid you are looking for
#包括
// [...]
std::ostringstream缓冲区;
int i=5;
缓冲器
int i = 3;
std::cout << "number " << i;
#include <sstream>
// [...]
std::ostringstream buffer;
int i = 5;
buffer << "number " << i;
std::string thestring = buffer.str(); // this is the droid you are looking for