Question 3
Back to Exercise
Given two variables a and b of the same struct type, which is true?
- A a == b does not compile; compare the members (or write a function) Correct
- B a == b compares all members
- C a == b compares their addresses
- D a == b compares only the first member
Correct Answer: Option A
C defines assignment for structs but not equality. memcmp(&a, &b, sizeof a) is also unsafe, because padding bytes may contain different garbage. Compare member by member.
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!