What will be the output of the following C code?
#include <stdio.h>
union u
{
struct p
{
unsigned char x : 2;
unsigned int y : 2;
};
int x;
};
int main()
{
union u u;
u.p.x = 2;
printf("%d\n", u.p.x);
}
#include <stdio.h>
union u
{
struct p
{
unsigned char x : 2;
unsigned int y : 2;
};
int x;
};
int main()
{
union u u;
u.p.x = 2;
printf("%d\n", u.p.x);
}
A. Compile time error
B. Undefined behaviour
C. Depends on the standard
D. 2
Answer: Option A
Join The Discussion