#include <sstream> // ostringstream のため
#include <string>  // string のため
 
// 文字列出力ストリーム
std::ostringstream oss;
int x = 10;
int y = 20;
int z = 500;
oss << "(" << x << "," << y << ") = " << z << std::endl;
 
// 文字列を取得
std::string s = oss.str();

tags: C++ zurazure

Posted by NI-Lab. (@nilab)