整数int能否转化成string?该怎么处理
整数int能否转化成string?
int a=12
string b="中国"
我上个帖子问题问的不对,我是想把a转化成string,能够实现a+b="12中国",这样的运算,
不知道能否实现!!
------解决方案--------------------
int a=12
string b="中国"
我上个帖子问题问的不对,我是想把a转化成string,能够实现a+b="12中国",这样的运算,
不知道能否实现!!
------解决方案--------------------
- C/C++ code
#include "stdafx.h" #include <sstream> #include <iostream> #include <string> using namespace std; void main() { int a=12; string b="中国"; ostringstream oss; oss<<a; string c=oss.str(); cout<<c<<b<<endl; system("pause"); }