atol()

Converts a character string to a value of type long.

  #include <stdlib.h>
  
  int atol(const char *nptr);    
Parameter

nptr

A pointer to the string to be converted.

Remarks

The atol() function converts the character array pointed to by nptr to an integer of type long int. Except for its behavior on error, this function is the equivalent of the call

strtol(nptr, (char **)NULL, 10);

This function sets the global variable errno to ERANGE if the converted value cannot be expressed as a value of type long int.

atol() returns an integer value of type long int.