初级问题,int如何转成字符串,以便MessageBox()输出

解决方案 »

  1.   

    int n=123;
    string s=itoa(n);
    MessageBox(s);
      

  2.   

    int x = 5;
    CString str;
    str.Format(_T("%i"), x);
    MessageBox(str);
      

  3.   

    用CString的话写成:
    CString work;
    work.Format("%d",i);
    不用CString的话,用sprintf(buff,"%d",i);
      

  4.   

    strCRC.Format("%d",i_crc);
    MessageBox(strCRC);
      

  5.   

    int a;
    CString str;
    str.Format("%d", a);
    MessageBox(str);
      

  6.   

    int n=111;
    MessageBox( "" + n );
      

  7.   

    int n=111;
    MessageBox( "" + n );
      

  8.   

    Cstring str;;
    str.format(_T("%d"),整数);
    messageBox(str);
      

  9.   

    TCHAR sz[20] = {0}; 
    wsprintf(sz,_T("%d"),number); 
    MessageBox(sz);
      

  10.   

    MFC:
    CString str;
    str.Format("%d", a);
    MessageBox(str);非MFC
    TCHAR sz[20] = {0}; 
    wsprintf(sz,_T("%d"),number); 
    MessageBox(sz);
      

  11.   

    纯 C int i = 123 ;
    char strMsg[20];
    memset(strMsg,0,sizeof(strMsg));
    sprintf(strMsg,"%d",i);
    MessageBox(strMsg);
      

  12.   

    int a = 100;

    CString str;str.Format("%d", a);

    MessageBox(str);
      

  13.   

    如果是纯C
    一般是 sprintf() 或是 itoa()如果VC, 一般用CString的Format方法
      

  14.   

    CString str ="";
    int a = 10;
    str.Format("%d", a);
    MessageBox(str);
      

  15.   

    stl sstreamint n = 0;
    std::ostringstream   os;
    os<< n;
    std::string strNum;
    strNum = os.str();
    MessageBox(strNum.c_str());
      

  16.   

    int x = 5;
    CString str;
    str.Format(_T("%i"), x);
    MessageBox(str);