function
The atoi () function converts a string in numeric format to an integer type. For example, the character string1253124127 is converted into the number1253124127.
pay attention to
Main attention
The Atoi function can be converted into the following string 1fdafhdjfhkas.
Matters needing attention about parameters
The parameter of the atoi () function is the string to be converted. The format of the string is
[space] [symbol] [number]
Among them, the space can be a space character in the keyboard or a tab; The symbol can be "+"for positive number or "-"for negative number; Numbers are strings of numbers. Therefore, the parameters of the atoi () function can be
+ 123
-456
It should be noted that spaces and "+"can be omitted. Therefore, the parameter of the atoi () function can also be
123
-456
Matters needing attention about return value
If the atoi () function is successfully converted, the return value of the function is the converted integer. If the conversion of atoi () function fails, for example, the type to be converted is beyond the range indicated by int, if the conversion is positive, it will return INT_MAX(2 147483647), if the conversion is negative, it will return INT_MIN(-2 147483648). The code is as follows
Calling method
//The format of this function is
Int atoi (constant char* str)
//where the parameter str is the string to be converted and the return value is the converted integer.
int main(){
const char * str 1 = " 124932657 13256 "
const char* str2="8fdafhdjfhkas "
int outNm=atoi(str 1)
}