{{keywords>wiki library source code example reference}}
====== atoi ======
#include
int atoi(const char *str);
convert a string to integer
===== C Sourcecode Example =====
#include /* including standard library */
//#include /* uncomment this for Windows */
#include
int main(void){
char string[]="1234";
int i;
printf("string = %s \n", string );
printf("int = %i \n", atoi(string) );
i = atoi(string);
i = i + i;
printf("i + i = %i\n", i);
return 0;
}
==== Output ====
Output:
user@host:~$ ./atoi
string = 1234
int = 1234
i + i = 2468