[ create a new paste ] login | about

Link: http://codepad.org/kAH1C6OU    [ 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[8] = "0182345";
   char *ptr;
   long ret;
   
   ret = strtol(str, &ptr, 0);
   if (*ptr != str[8] + 0) {
            printf("%s %d\n",ptr,str[8] + 0);
            puts("Invalid numeric literal");
   } else {
     printf("*** %s *** %s\n",ptr,str[8]);
      printf("%o octal is in decimal %ld\n", ret,ret);

   }
   return(0);
}


Output:
1
2
82345 0
Invalid numeric literal


Create a new paste based on this one


Comments: