[ create a new paste ] login | about

Link: http://codepad.org/adcvmgbA    [ raw code | output | fork ]

slevy1ster - C, pasted on Oct 30:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include <stdlib.h>

int main()
{
   char str[30] = "0128912";
   char *ptr;
   long ret;
   
   ret = strtol(str, &ptr, 0);
   if (ptr != str + 0) {
            puts("Invalid numeric literal");
   }
   else
   {
      printf("\n%s in decimal is %ld\n", ret);

   }
   return(0);
}


Output:
1
Invalid numeric literal


Create a new paste based on this one


Comments: