/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdlib.h>
#include <stdio.h>

void test(char *s)
{
   int v;
   char *ep;
   v = atoi(s);
   printf("%s = %d\n", s, v);
   v = strtol(s, &ep, 10);
   if(ep > s)
       printf("%s = %d\n", s, v);
   else
       printf("%s = not an integer\n");
   v = strtol(s, &ep, 8);
   if(ep > s)
       printf("%s = %d\n", s, v);
   else
       printf("%s = not an integer\n");
   v = strtol(s, &ep, 0);
   if(ep > s)
       printf("%s = %d\n", s, v);
   else
       printf("%s = not an integer\n");
}

int main()
{
    test("123");
    test("0123");
    return 0;
}
