C atol() function

The atol() functions used to convert string data type to long data type. The syntax is as follows :
long int atol( const char * str );
Example :
#include <stdio.h>
#include <stdlib.h>

int main() {
  char str[] = "1000000000000";
  long num = atol(str);
  printf("Value of num is : %ld\n", num);
  return 0;
Output :

Value of num is : 1000000000000

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

Next : C Language Tutorials List