converting from char * to int on result from strtok
converting from char * to int on result from strtok
input is something like "word-2"
How do I convert from char pointer to int ?
- char *tmp_result = NULL;
- char standard = "";
- int version = 0;
- tmp_result = strtok( argv[1], delims );
- printf( "token standard is "%s"
", tmp_result ); - standard = *tmp_result;
- if( tmp_result != NULL ) {
- tmp_result = strtok( NULL, delims );
- printf( "token tmp_result is "%s"
", tmp_result ); <===== prints "2" as it should be - version = *tmp_result;
- printf( "token as_version is "%d"
", as_version ); <===== prints "50" after assignment
Login