#include <stdio.h>void F0 (void) {printf ("in linux:\n"); printf ("sizeof (char) =%d\n", sizeof (char)); printf ("sizeof (int) =%d\n", sizeof (int)); printf ("sizeof (short int) =%d\n", sizeof (short int)); printf ("sizeof (long int) =%d\n", sizeof (long int)); printf ("sizeof (float) =%d\n", sizeof (float)); printf ("sizeof (double) =%d\n", sizeof (double)); printf ("sizeof (long double) =%d\n", sizeof (long double)); }void F1 (void) {int i = 1; unsigned int ui = 1; char c = 1; unsigned char UC = 1; short int si = 1; unsigned short int usi = 1; float f = 1; Double d = 1; Long double ld = 1; printf ("for 1, i =%x, UI =%x\n", I, UI); printf ("for 1, C =%x, UC =%x\n", c, UC); printf ("for 1, si =%x, usi =%x\n", si, USI); printf ("for 1, F =%x\n", f); printf ("for 1, D =%x\n", d); printf ("for 1, ld =%x\n", LD); }void F2 () {int i =-1; unsigned int ui =-1; char C =-1; unsigned char UC =-1; short int si =-1; unsigned short int usi =-1; float f =-1; Double d =-1; Long double ld =-1; printf ("for-1, I =%x, UI =%x\n", I, UI); printf ("for-1, C =%x, UC =%x\n", c, UC); printf ("for-1, si =%x, usi =%x\n", si, USI); printf ("for-1, F =%x\n", f); printf ("for-1, D =%x\n", d); printf ("for-1, ld =%x\n", LD); c =-255; UC =-255; printf ("for-255, C =%x, UC =%x\n", c, UC); c =-128; UC =-128; printf ("for-128, C =%x, UC =%x\n", c, UC);} void F_show1 (void) {printf ("For-1,f_show1:uint =%x\n", (unsigned int)-1); printf ("For-1,f_show1:int =%x\n", (int)-1); printf ("For-1,f_show1:c =%x\n", (char)-1); printf ("For-1,f_show1:uc =%x\n", (unsigned char)-1); printf ("For-1,f_show1:uc =%d\n", (unsigned char)-1);} int main () {F0 (); F_show1 (); F1 (); F2 (); return 0;} /*[email protected]:/work/dcc# GCC 1.c;./a.out in linux:sizeof (char) = 1sizeof (Int.) = 4sizeof (short int) = 2sizeof (long int) = 4sizeof (float) = 4sizeof (double) = 8sizeof (long double) = 12
Here is a description of the integer constants in the Linux system. means for-1,f_show1:uint = Fffffffffor-1,f_show1:int = Fffffffffor-1,f_show1:c = Fffffffffor-1,f_show1:uc = Fffor-1 , F_show1:uc = 255for 1, i = 1, ui = 1for 1, c = 1, UC = 1for 1, si = 1, usi = 1for 1, f = 0for 1, d = 0for 1, ld = 0for- 1, i = ffffffff, UI = fffffffffor-1, c = ffffffff, UC = fffor-1, si = ffffffff, usi = fffffor-1, F = 0for-1, d = 0for -1, ld = 0for-255, c = 1, UC = 1for-128, c = ffffff80, UC = 80*/
C Language, data type