User Tools

Site Tools


c:stdlib.h:atoi

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:stdlib.h:atoi [2024/02/16 01:04] (current)
Line 1: Line 1:
 +{{keywords>wiki library source code example reference}}
 +====== atoi ======
 +<code c>
 +    #include <stdlib.h>
 +    int atoi(const char *str);
 +</code>    
 +    convert a string to integer
 +
 +===== C Sourcecode Example =====    
 +<code c>
 +#include <stdio.h> /* including standard library */
 +//#include <windows.h> /* uncomment this for Windows */
 +
 +#include <stdlib.h>
 +
 +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;
 +}
 +
 +</code>
 +
 +==== Output ====
 +
 +    Output:
 +    user@host:~$ ./atoi 
 +    string = 1234 
 +    int = 1234 
 +    i + i = 2468
 +
  

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/stdlib.h/atoi.txt · Last modified: 2024/02/16 01:04 (external edit)

Impressum Datenschutz