size of struct and corresponding variable

前端 未结 6 1079
慢半拍i
慢半拍i 2021-01-14 07:53

If i define a char variable

char a;

and a structure with a single char member

struct OneChar {
char a;
};
<
6条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-14 08:35

    All as will have the same size, no matter if they stand alone or are inside a structure.

    What may happen inside a structure is that there is padding between members ... but that may also happen in "stand alone" variables.

提交回复
热议问题