Machine-translated by Google. Questions are authored in English.
Top

Discussion

A union is used in embedded code chiefly to

  • A.reduce the alignment requirement of its members
  • B.guarantee that its members are contiguous in memory
  • C.allow several members to be initialised at once
  • D.view the same storage as more than one type

Answer: D

Correct answer: view the same storage as more than one type

A union overlays its members on the same bytes, so a 32-bit word can be examined as four bytes or a float inspected bitwise. That reinterpretation is its purpose. It does not reduce alignment - a union takes the strictest requirement of its members - and only one member holds a valid value at a time.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.