atoi (): str turn int

description

C library function int atoi (const char * str) the parameter str string pointed to convert to an integer (of type int type).

statement

Here is () statement atoi function.

int atoi ( const  char * str)

parameter

  • STR - string to be converted to an integer.

return value

This function returns after a long integer conversion, if the conversion is not performed effectively, zero is returned.

Examples

The following example demonstrates atoi () function usage.

#include <stdio.h> 
#include <stdlib.h> 
#include < String .h> int main () 
{ int Val;
    char STR [ 20 is ]; 
   strcpy (STR, " 98,993,489 " ); 
   Val = atoi (STR) ; 
   the printf ( " string value =% s,% integer value D = \ n- " , STR, Val); 
   strcpy (STR, " runoob.com " ); 
   Val = atoi (STR); 
   the printf ( " string value =% s,% integer value D = \ n- " , STR, Val); return


   
   


   (0);
}

References:

Rookie Tutorial

Guess you like

Origin www.cnblogs.com/xumaomao/p/11990771.html