c++中, 整型和字符型常量怎么实现相加? 然后以字符型常量输出..

2025-05-16 03:23:06
推荐回答(4个)
回答(1):

#include

string wor = "tbs"
int a = 12
int b = 11

wor=wor+ itoa(a)+itoa(b)

string可能也有format类方法吧

回答(2):

string word = "tbs&11&12&"
这种不是整型和字符型常量相加,这是在字符串后面增加字符.
还有一个概念要弄清楚,常量是不能相加赋值的.

回答(3):

MFC工程中是这样的 :

CString str = "tbs";
int a = 12 ;
int b = 11 ;
CString str1;
str1.Format("%s&%d&%d", str, b,a);
要输出的话 随便show个对话框出来,加上MessageBox(str1);这句

回答(4):

这个吗。。。