Keil Logo


#include <stdlib.h>

long atol (
  const unsigned char *string);   /* string to convert */

The atol function converts string into a long integer value. The input string must be a sequence of characters that can be interpreted as a long integer. This function stops processing characters from string at the first one it cannot recognize as part of the number.

The string passed to atol must have the following format:

〚whitespace〛 〚{+|-}〛 digits



May be any number of space(' '), tab ('\t'), newline ('\n'), or carriage return ('\r') characters.


May be one or more decimal digits.
Return Value

The atol function returns the long integer value that is produced by interpreting the characters in string as a number.

If no conversion could be performed, 0 is returned.

See Also

atof, atoi

#include <stdlib.h>
#include <stdio.h> /* for printf */

void tst_atol (void) {
  long l;
  char s [] = "8003488051";

  l = atol (s);
  printf ("ATOL(%s) = %ld\n", s, l);
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.