struct Flat {
int a1;
int a2;
}
// a hierarchical struct which containing a struct attribute
struct NonFlat {
Flat b1;
int b2;
}
Flat f1, f2;
memcmp (&f1, &f2, sizeof f1)
in my compiler, it works, meaning
f1.a1 == f2.a1, f1.a2 == f2.a2 <=> memcmp (f1, f2) == 0;
NonFlat n1, n2;
memcmp (&n1, &n2, sizeof n1) // does it also work for non-flat structs, considering the padding?
I assume it should also work for NonFlat structs. However, in my compiler, for non-flat structs, it seems even though the member attributes are equal, the result of memcmp indicates they are different.