關於64位機器的c語言中各個類型的字節數

 ==sizeof-a=8, sizeof-b=12, sizeof int=4
 ==sizeof-*p=8, sizeof-short=2 sizeof char=1
 ==sizeof long=8, sizeof -double=8, sizeof float=4

 

#include <stdio.h>

struct a{
   short s;
   char  c;
   int   i;
};

struct b {
   char c;
   int  i;
   short s;
};
int main() {
   printf(" ==sizeof-a=%d, sizeof-b=%d, sizeof int=%d\n", sizeof(struct a), sizeof(struct b), sizeof(int));
   printf(" ==sizeof-*p=%d, sizeof-short=%d sizeof char=%d\n", sizeof(int*), sizeof(short), sizeof(char));
   printf(" ==sizeof long=%d, sizeof -double=%d, sizeof float=%d\n", sizeof(long), sizeof(double), sizeof(float));
   return 0;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章