Question 10
Back to Exercise
In C11, a struct contains union { int i; float f; }; with no member name. How do you reach i for a variable v?
- A v.union.i
- B v.i Correct
- C v->i
- D It is not accessible
Correct Answer: Option B
Members of an anonymous union (or struct) are treated as members of the enclosing struct, so you write v.i. This was standardised in C11.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!