首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

整数int能否转化成string?该怎么处理

2012-06-17 
整数int能否转化成string?inta12string b中国我上个帖子问题问的不对,我是想把a转化成string,能够实现

整数int能否转化成string?
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");} 

热点排行