CString str1;
int int1=1;
str1.Format("%i",int1);

解决方案 »

  1.   

    Example/* ATOF.C: This program shows how numbers stored
     * as strings can be converted to numeric values
     * using the atof, atoi, and atol functions.
     */#include <stdlib.h>
    #include <stdio.h>void main( void )
    {
       char *s; double x; int i; long l;   s = "  -2309.12E-15";    /* Test of atof */
       x = atof( s );
       printf( "atof test: ASCII string: %s\tfloat:  %e\n", s, x );   s = "7.8912654773d210";  /* Test of atof */
       x = atof( s );
       printf( "atof test: ASCII string: %s\tfloat:  %e\n", s, x );   s = "  -9885 pigs";      /* Test of atoi */
       i = atoi( s );
       printf( "atoi test: ASCII string: %s\t\tinteger: %d\n", s, i );   s = "98854 dollars";     /* Test of atol */
       l = atol( s );
       printf( "atol test: ASCII string: %s\t\tlong: %ld\n", s, l );
    }
    Outputatof test: ASCII string:   -2309.12E-15   float:  -2.309120e-012
    atof test: ASCII string: 7.8912654773d210   float:  7.891265e+210
    atoi test: ASCII string:   -9885 pigs      integer: -9885
    atol test: ASCII string: 98854 dollars      long: 98854
      

  2.   

    CString str1;
    int int1=1;
    str1.Format("%d",int1); 
    也成
      

  3.   

    最好的方法是调用wsprintf,这个函数是user32中的,所以用这个函数不需要任何额外的库
      

  4.   

    long x=1000;
    char buf[10];
    CString NewText(_itoa(x,buf,10));
    //10是代表10进制的意思,凭记忆写的,可能有错,见谅 
      

  5.   

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