[ create a new paste ] login | about

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

slevy1ster - C, pasted on Dec 31:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
    char *p, *s;
    long li;

    s = "20y";
    li = strtol(s,&p,0);
li = strtol(s,NULL,10);   /* assigns 20 to li */
printf("%s in Base 10: %ld\n", s,li);
li = strtol(s,NULL,8);   /* assigns 16 to li */
printf("%s in Base 8: %ld\n",s,li);
return 0;
}


Output:
1
2
20y in Base 10: 20
20y in Base 8: 16


Create a new paste based on this one


Comments: