C atoi() function

The atoi() function is used to converts the string data type to int data type. The syntax of atoi() is as follows :
 int atoi( const char * str );
Where str is the string you want to convert.

Example :
#include <stdio.h>
#include <stdlib.h>

int main() {
  char str[] = "2000";
  int num = atoi(str);
  printf("num = %d\n", num);
  return 0;
Output :

num = 2000

Note : The atoi() function is predefined on the "stdlib.h" standard library file.

Next : C Language Tutorials List