显示内容为一个字符串加一个数字CString d1;
int s1;
d1=......;
s1=......;
如何在一个MessageBox中显示d1+s1的内容

解决方案 »

  1.   

    CString d1;
    int s1;
    d1="test";
    s1=10;
    CString stmp;
    stmp.Format("%d",s1);
    d1+=stmp;
    MessageBox(d1);
      

  2.   

    CString str;
    str.Format("%s%d",d1,s1)
      

  3.   

    CString s2;
    s2.Format( "%s%d", d1, s1 );
    MessageBox( NULL, s2, NULL, MB_OK );如果d1的内容可以改变,也可以不用中间变量
    d1.Format( "%s%d", d1, s1 );
    MessageBox( NULL, d1, NULL, MB_OK );
      

  4.   

    如楼上所说
    CString str;
    str.Format("%s%d",d1,s1)
    AfxMessageBox(str);
      

  5.   

    谢谢,还想问一句,如果s1为double型又怎样写呀