Thunder Bird
Communication & Improvement
posts - 47,  comments - 155,  trackbacks - 0
第一种方法:
int i=9;
char num[20];
itoa(i,num,10);
10 is radix

第二种方法:
include <ostringstream>
string num;
int i=9;
ostringstream ostr;
ostr<<i;
num = ostr.str();
posted on 2006-10-14 06:48 Thunder 阅读(2971) 评论(3)  编辑 收藏 引用

FeedBack:
# re: C++ convert int to string
2006-10-19 12:11 | DELL网站
好文,学习中,,  回复  更多评论
  
# re: C++ convert int to string
2006-10-24 10:18 | 李珍宝
也可以这样用

#include <boost/lexical_cast.hpp>
int i=9;
string s=boost::lexical_cast<string>(i);


不过,先要下载boost库。
  回复  更多评论
  
# re: C++ convert int to string
2007-08-07 23:58 | GBY
sprintf:)  回复  更多评论
  
只有注册用户登录后才能发表评论。

<2006年10月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(8)

随笔档案

相册

搜索

  •  

最新评论

阅读排行榜

评论排行榜