[ create a new paste ] login | about

Link: http://codepad.org/mZRZaD3x    [ 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
#include <stdio.h>
#include <stdlib.h>

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

   }
   return(0);
}


Output:
1
123 octal is in decimal 83


Create a new paste based on this one


Comments: