急用,如何用AfxMessageBox()显示一个整数变量的值?
我只会用:AfxMessageBox("nihaoma");
可是如何显示一个整数变量:int i;  afxmessagebox(i);

解决方案 »

  1.   

    AfxMessageBox(itoa(i, "%d", 10));
      

  2.   

    你将int i 先转换成CString类型的不就可以了啊
    CString temp;
    temp.Format("%d",i);
    AfxMessageBox(temp);
      

  3.   

    更正
    char buf[65];
    itoa(i, buf, 10);
      

  4.   

    CString temp;
    temp.Format("%d",i);
    AfxMessageBox(temp);
    我一般也用这个
      

  5.   

    itoachar buffer[20];
       int  i = 3445;
       long l = -344115L;
       unsigned long ul = 1234567890UL;   _itoa( i, buffer, 10 );
       printf( "String of integer %d (radix 10): %s\n", i, buffer );
       _itoa( i, buffer, 16 );
       printf( "String of integer %d (radix 16): 0x%s\n", i, buffer );
       _itoa( i, buffer, 2  );
       printf( "String of integer %d (radix 2): %s\n", i, buffer );   _ltoa( l, buffer, 16 );
       printf( "String of long int %ld (radix 16): 0x%s\n", l, 
                                                        buffer );   _ultoa( ul, buffer, 16 );
       printf( "String of unsigned long %lu (radix 16): 0x%s\n", ul,
                                                        buffer );