rt

解决方案 »

  1.   

    std::string aStr("4");
    int aVal = atoi(aStr.c_str());
      

  2.   

    char *str="4";
    int a=atoi(str);
      

  3.   

    CString strTemp = "4";
    int     iTemp   = atoi(strTemp);这样就搞定了!相反可以用itoa!祝你进步!
      

  4.   

    CString str="4";
    int i=atoi(str.GetBuffer(0));
      

  5.   

    int atoi( const char *string );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;
       int i1,i2;
       CString m;   s = "4";      /* Test of atoi */
       m="4";
       i1 = atoi( s );
       i2=atoi(m);
       printf( "atoi test: ASCII string: %s\t\tinteger: %d\n", s, i1 );
       printf( "atoi test: ASCII string: %m\t\tinteger: %d\n", s, i2 );}