-
Notifications
You must be signed in to change notification settings - Fork 1
/
strtol.c
35 lines (28 loc) · 897 Bytes
/
strtol.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
int i;
int ret;
unsigned int uret;
char *ptr;
if (argc < 2) {
printf("Usage: ./a.out <input>\n");
return -1;
}
for (i = 1; i < argc; i++) {
printf("argv[%d] = %s\n", i, argv[i]);
ret = strtol(argv[i], &ptr, 0);
printf("strtol %d, %u, 0x%x\n", ret, ret, ret);
printf("%s\n", ret > 0 ? "> 0" : "< 0");
uret = strtoul(argv[i], &ptr, 0);
printf("strtoul %d, %u, 0x%x\n", uret, uret, uret);
printf("%s\n", uret > 0 ? "> 0" : "< 0");
}
printf("sizeof(long long) %ld\n", sizeof(long long));
printf("sizeof(long int) %ld\n", sizeof(long int));
printf("sizeof(int) %ld\n", sizeof(int));
printf("sizeof(unsigned long long) %ld\n", sizeof(unsigned long long));
printf("sizeof(unsinged long int) %ld\n", sizeof(unsigned long int));
printf("sizeof(unsigned int) %ld\n", sizeof(unsigned int));
}