I'm facing a strange result sizeof()
during testing.
How T1
and T2
are the same size as the types used in T2
is smaller than T1
?
#include <iostream>
using namespace std;
struct T1 {
int id;
int enable;
};
struct T2 {
int id;
char enable;
};
int main() {
cout << sizeof(T1) << endl; // Print 8
cout << sizeof(T2) << endl; // Print 8
return 0;
}