|
发表于 2019-3-7 11:42:15
|
显示全部楼层
明白了,你这道题说白了就是如何将整形数字转成字符串,我给你列出三种方法:
- int aa = 1;
- //1、如果你当前是MFC工程的话,可以使用CString这个类的Format方法来讲int转为CString
- CStringA strText;
- strText.Format("%d", aa);
- MessageBoxA(NULL, strText, "标题1", 0);
- //2、使用 sprintf 格式化字符串,将int转为char数组的字符串
- char szText[20] = { 0 };
- sprintf(szText, "%d", aa);
- MessageBoxA(NULL, szText, "标题2", 0);
- //3、使用 itoa 函数,将int转为char数组的字符串
- char szMsg[20] = { 0 };
- itoa(aa, szMsg, 10);
- MessageBoxA(NULL, szMsg, "标题3", 0);
复制代码 |
|