20131031【C言語】構造体のサイズを調べる

お題

構造体のサイズを調べる

 

プログラム概要

定義した構造体のサイズを表示する

 

ソース

#include <stdio.h>

 

struct s_type {

int i;

char ch;

int *p;

double d;

} s;

 

int main(void)

{

printf("s_type size is %d bytes.\n", sizeof(struct s_type));

 

return 0;

}

 

実行結果

# ./a.out 

s_type size is 24 bytes.