#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> void old (char *str) { long num; num = atol (str); printf ("ATOL\n----\n"); printf ("Your number is %ld\n", num); } void new (char *str) { long num; char *ptr; num = strtol (str, &ptr, 0); printf ("\nSTRTOL\n------\n"); if (errno) { fprintf (stderr, "Error: %s\n", strerror (errno)); return; } printf ("Your number is %ld\n", num); printf ("And the end pointer was %s\n", ptr); } int main (void) { char *str; printf ("Input a string: "); scanf ("%ms", &str); old (str); new (str); return 0; }