In have this code:
#include <iostream>
using namespace std;
int main() {
struct people {char name[50]; int tt; int gg;};
struct people p1;
cout << sizeof(p1);
return 0;
}
the output is 60. Why?, I mean, the struct
just would need to have 50+4+4=58 bytes. If we change the name[50]
to name[20]
, we have the output: 28 as expected.
It is not contradicting that the memory used by the members of the struct are contiguous?.