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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
int main (int argc, const char * argv[])
{
   char char1;
   unsigned char unsigned_char1;
   signed char signed_char1;

   short int short_int1;
   signed short int signed_short_int1;
   unsigned short int unsigned_short_int;

   int int1;
   signed int signed_int1;
   unsigned int unsigned_int1;

   long int long_int1;
   signed long int long_signed_int1;
   unsigned long int long_unsigned_int1;

   float float1;
   double double1;

   int *needle;

   struct{
       char a;
       char b;
   }struct1;


   printf("char's size is %d \n",sizeof(char1));
   printf("unsigned_char's size is %d \n",sizeof(unsigned_char1));
   printf("signed_char's size is %d \n",sizeof(signed_char1));

   printf("short_int1's size is %d \n",sizeof(short_int1));
   printf("signed_short_int1's size is %d \n",sizeof(signed_short_int1));
   printf("unsigned_short_int's size is %d \n",sizeof(unsigned_short_int));

   printf("int1's size is %d \n",sizeof(int1));
   printf("signed_int1's size is %d \n",sizeof(signed_int1));
   printf("unsigned_int1's size is %d \n",sizeof(unsigned_int1));

   printf("long_int1's size is %d \n",sizeof(long_int1));
   printf("long_signed_int1's size is %d \n",sizeof(long_signed_int1));
   printf("long_unsigned_int1's size is %d \n",sizeof(long_unsigned_int1));

   printf("float1's size is %d \n",sizeof(float1));
   printf("double1's size is %d \n",sizeof(double1));

   printf("needle(64bit)'s size is %d \n",sizeof(needle));

   printf("struct1's size is %d \n",sizeof(struct1));
//    printf("'s size is %d \n",sizeof());    
   return 0;
}

Output

char's size is 1

unsigned_char's size is 1

signed_char's size is 1

short_int1's size is 2

signedshortint1's size is 2

unsignedshortint's size is 2

int1's size is 4

signed_int1's size is 4

unsigned_int1's size is 4

long_int1's size is 8

longsignedint1's size is 8

longunsignedint1's size is 8

float1's size is 4

double1's size is 8

needle(64bit)'s size is 8

struct1's size is 2