/* atol example */
#include <stdio.h> /* printf, fgets */
#include <stdlib.h> /* atol */
int main ()
{
longint li;
char buffer[256];
printf ("Enter a long number: ");
fgets (buffer, 256, stdin);
li = atol(buffer);
printf ("The value entered is %ld. Its double is %ld.\n",li,li*2);
return 0;
}
输出
Enter a number: 567283
The value entered is 567283. Its double is 1134566.