12_stdlib_convert.c (391B)
1 /* stdlib.h numeric conversion + abs. */ 2 3 #include <stdio.h> 4 #include <stdlib.h> 5 6 int main(void) { 7 if (atoi("42") != 42) return 1; 8 if (atoi("-7") != -7) return 2; 9 if (strtol("0xcafe", NULL, 16) != 0xcafe) return 3; 10 if (strtol("777", NULL, 8) != 511) return 4; 11 if (abs(-13) != 13) return 5; 12 if (labs(-1234567890L) != 1234567890L) return 6; 13 14 printf("stdlib ok\n"); 15 return 0; 16 }