总结了网上的几种方法:
1. 指针操作(这种方法可能适用于传参数时用,但是像messagebox函数中就不适用)
LPCTSTR p; int x = 100; p = (LPCTSTR)&x;
转自 http://zhidao.baidu.com/question/46371231.html
2. format 函数
int number = 1;
CString t;
t.Format(_T("%d"), number);
AfxMessageBox(t);
转自 http://social.msdn.microsoft.com/Forums/en/vclanguage/thread/f202b3df-5849-4d59-b0d9-a4fa69046223
3. itoa 函数 (linux gcc 中不支持该函数)
- int i=5;
- itoa(i,temp,10);///将i转换为字符串放入temp中,最后一个数字表示十进制
- itoa(i,temp,2); ///按二进制方式转换
转自 http://conkeyn.iteye.com/blog/229992
4. sprintf 或 sscanf函数
int ss;
char temp[64];
ss = 1000;
sprintf(temp, "%d", ss);
自己上网查吧,好多