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

解决方案 »

  1.   

    long atol( const char *string );
      

  2.   

    atol(fff);
    也是一样不行,还有其它的方法吗?
      

  3.   

    照着例子做,用strtod();
    /* STRTOD.C: This program uses strtod to convert a
     * string to a double-precision value; strtol to
     * convert a string to long integer values; and strtoul
     * to convert a string to unsigned long-integer values.
     */#include <stdlib.h>
    #include <stdio.h>void main( void )
    {
       char   *string, *stopstring;
       double x;
       long   l;
       int    base;
       unsigned long ul;
       string = "3.1415926This stopped it";
       x = strtod( string, &stopstring );
       printf( "string = %s\n", string );
       printf("   strtod = %f\n", x );
       printf("   Stopped scan at: %s\n\n", stopstring );
       string = "-10110134932This stopped it";
       l = strtol( string, &stopstring, 10 );
       printf( "string = %s", string );
       printf("   strtol = %ld", l );
       printf("   Stopped scan at: %s", stopstring );
       string = "10110134932";
       printf( "string = %s\n", string );
       /* Convert string using base 2, 4, and 8: */
       for( base = 2; base <= 8; base *= 2 )
       {
          /* Convert the string: */
          ul = strtoul( string, &stopstring, base );
          printf( "   strtol = %ld (base %d)\n", ul, base );
          printf( "   Stopped scan at: %s\n", stopstring );
       }
    }
      

  4.   

    1、无论atol或是atoi都会对串中的字符进行基于10进制的检索,只要遇到非法字符即告转换结束,所以对“FF0000”的检索结束于第一个“F”,函数恒返回0;
    2、可以试一下strtol函数,int ii = strtol(fff,NULL,0x10);
      

  5.   

    谢谢lkwalk(一壶酌酒)
    Icic(Icic)
    (排名不分先后)
    送分!