1 /* types.c -- find out size of data types */
44 int main(int argc
, char * argv
[])
47 printf("type bytes\n");
48 printf("---------------\n");
49 printf("char %d\n", sizeof(char));
50 printf("char * %d\n", sizeof(char *));
51 printf("void * %d\n", sizeof(void *));
52 printf("short int %d\n", sizeof(short int));
53 printf("int %d\n", sizeof(int));
54 printf("long %d\n", sizeof(long));
55 printf("long int %d\n", sizeof(long int));
56 printf("long long %d\n", sizeof(long long));
57 printf("size_t %d\n", sizeof(size_t));
58 printf("float %d\n", sizeof(float));
59 printf("double %d\n", sizeof(double));
60 printf("long double %d\n", sizeof(long double));
61 printf("wchar_t %d\n", sizeof(wchar_t));
64 printf("format input output\n");
65 printf("------------------------------------------------\n");
66 printf("%%d 0xffffffff %d\n", 0xffffffff);
67 printf("%%u 0xffffffff %u\n", 0xffffffff);
68 printf("%%d 0x7fffffff %d\n", 0x7fffffff);
69 printf("%%u 0x7fffffff %u\n", 0x7fffffff);
70 printf("%%d 0x80000000 %d\n", 0x80000000);
71 printf("%%u 0x80000000 %u\n", 0x80000000);
72 printf("%%d 0x7fffffffffffffffLL %d\n", 0x7fffffffffffffffLL
);
73 printf("%%u 0x7fffffffffffffffLL %u\n", 0x7fffffffffffffffLL
);
74 printf("%%x 0xffffffffffffffffLL %x\n", 0xffffffffffffffffLL
);
75 printf("%%X 0x7fffffffffffffffLL %x\n", 0x7fffffffffffffffLL
);
76 printf("%%X 0x8000000000000000LL %x\n", 0x8000000000000000LL
);
77 printf("%%llX 0xFFFFFFFFFFFFFFFFLL %x\n", 0xFFFFFFFFFFFFFFFFLL
);
78 printf("%%llX 0x7FFFFFFFFFFFFFFFLL %x\n", 0x7FFFFFFFFFFFFFFFLL
);
79 printf("%%llX 0x8000000000000000LL %x\n", 0x8000000000000000LL
);
81 printf("%%lld 0xffffffffffffffffLL %lld\n", 0xFFFFFFFFFFFFFFFFLL
);
82 printf("%%llu 0xffffffffffffffffLL %llu\n", 0xFFFFFFFFFFFFFFFFLL
);
83 printf("%%lld 0x7fffffffffffffffLL %lld\n", 0x7fffffffffffffffLL
);
84 printf("%%llu 0x7fffffffffffffffLL %lld\n", 0x7fffffffffffffffLL
);
85 printf("%%lld 0x8000000000000000LL %lld\n", 0x8000000000000000LL
);
86 printf("%%llu 0x8000000000000000LL %llu\n", 0x8000000000000000LL
);
88 printf("%%ld 0xffffffffffffffffLL %ld\n", 0xFFFFFFFFFFFFFFFFLL
);
89 printf("%%lu 0xffffffffffffffffLL %ld\n", 0xFFFFFFFFFFFFFFFFLL
);
90 printf("%%ld 0x7fffffffffffffffLL %ld\n", 0x7FFFFFFFFFFFFFFFLL
);
91 printf("%%lu 0x7fffffffffffffffLL %lu\n", 0x7FFFFFFFFFFFFFFFLL
);
92 printf("%%ld 0x8000000000000000LL %ld\n", 0x8000000000000000LL
);
93 printf("%%lu 0x8000000000000000LL %lu\n", 0x8000000000000000LL
);