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

Discussion

Which of the following operators can be applied on structure variables?

  • A.Equality comparison ( == )
  • B.Assignment ( = )
  • C.Both of the above
  • D.None of the above

Answer: B

Correct answer: Assignment ( = )

A structure may be assigned as a whole, which copies it member by member. It may not be compared with ==: the compiler could not simply compare the bytes, because padding between members holds unspecified values, and comparing member by member is left to the programmer.

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

Post your comment

Please log in or register to post a comment.