struct s{
double a;
char b;
double c;
int d;
};
created
last reply
- 3
replies
- 1.2k
views
- 4
users
- 1
link
struct s{
double a;
char b;
double c;
int d;
};
This is because of Padding. Depending on the machine the word size may vary, your machine has a word size of 4 bytes meaning it would pad the extra number bytes for each data entry to be able read word chunks while performing operations.
double a; 8 Bytes ( No Padding Required as multiple of 4 )
char b; ( 1 Bytes , Requires 3 Bytes of Padding )
double c; 8 bytes ( No Padding required )
int d; ( 4 Bytes )
8 + 1 + 3 + 8 + 4 = 24
Topic | Category | Replies | Views | Activity |
---|---|---|---|---|
Hosting a competition on SPOJ | Off-topic | 1 | 80 | Apr 9 |