如题!!!

解决方案 »

  1.   


       s = "98854 dollars";     /* Test of atol */
       l = atol( s );
       printf( "atol test: ASCII string: %s\t\tlong: %ld\n", s, l );
      

  2.   

    _atoi()函数,在msdn里查使用方法,以及相关函数。
      

  3.   

    CString str = "123";
    int res = atoi(str);
      

  4.   

    用 sscanf
    例子:
    #include <stdio.h>void main( void )
    {
       char  tokenstring[] = "15 12 14...";
       float fp;   /* Input various data from tokenstring: */  
       sscanf( tokenstring, "%f", &fp );   /* Output the data read */
       printf( "Real:     = %f\n", fp );
    }OutputReal:     = 15.000000
      

  5.   

    反过去的话,相应地用sprintf;用 sscanf
    例子:
    #include <stdio.h>void main( void )
    {
       char  tokenstring[10];
       float fp=15;   /* Input various data from tokenstring: */  
       sprintf( tokenstring, "Real: %f", &fp );   /* Output the data read */
       printf( "%s\n", tokenstring);
    }OutputReal:  = 15.000000
      

  6.   

    (上面手误)
    反过去的话,相应地用sprintf;
    #include <stdio.h>void main( void )
    {
       char  tokenstring[10];
       float fp=15;   /* Input various data from tokenstring: */  
       sprintf( tokenstring, "Real: %f", fp );   /* Output the data read */
       printf( "%s\n", tokenstring);
    }OutputReal:  = 15.000000
      

  7.   

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