std::string aStr("4"); int aVal = atoi(aStr.c_str());
char *str="4"; int a=atoi(str);
CString strTemp = "4"; int iTemp = atoi(strTemp);这样就搞定了!相反可以用itoa!祝你进步!
CString str="4"; int i=atoi(str.GetBuffer(0));
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 );}
int aVal = atoi(aStr.c_str());
int a=atoi(str);
int iTemp = atoi(strTemp);这样就搞定了!相反可以用itoa!祝你进步!
int i=atoi(str.GetBuffer(0));
* 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 );}