Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What is the function of converting character variables into integer variables in language?
What is the function of converting character variables into integer variables in language?
If the character type is char, it can be calculated directly as long as it is cast.

If it is a string, it is char*, using atoi:

int atoi(char *str)

The string to be converted to an integer.

For example:

# include & ltstdlib.h & gt

# include & ltstdio.h & gt

int main(void)

{

int n;

char * str = " 12345.67 ";

n = atoi(str);

printf("string = %s integer = %d ",str,n);

Returns 0;

}