+ 1

C program.....why does this program return size 24?

Size of operator https://code.sololearn.com/czCnEtHpYjWN/?ref=app

16th Jun 2019, 6:14 PM
Abhijeet Pawar
Abhijeet Pawar - avatar
2 odpowiedzi
+ 16
The size of a structure is equal to 'or greater than' the sum of the sizes of its members. For example, struct s { char ch; int i; double f; } s_var; Here, sizeof(s_var) is at least 13 (8+4+1). However, the size of 's_var' might be greater because the compiler is allowed to pad a structure in order to achieve word or paragraph alignment. (A paragraph is 16 bytes.) Since the size of a structure may be greater than the sum of the sizes of its members, you should always use 'sizeof' when you need to know the size of a structure.
16th Jun 2019, 6:46 PM
Danijel Ivanović
Danijel Ivanović - avatar