3 ms·
That's why I said "not always". Here is an example which will print different result if you define #define union struct Here you go: #include <stdio.h>
by piokuc 12y ago
That's why I said "not always". Here is an example which will print different result if you define
#define union struct
Here you go:
#include <stdio.h>
union U { char a; char b; };
int main() {
U u;
u.a = 13;
u.b = 10;
printf("%d\n", int(u.a));
return 0;
}
- to3m 12y agoI don't think a and b need necessarily overlap. I think the types need to be more like this: struct A {char a;}; struct B {char a;}; union U {struct A a; struct B b;};