Practice mode C Language

Which operation can be applied directly to two whole structure variables of the same type in C?

Correct answer A. Assignment with =

Explanation

Structures of the same type can be assigned, passed to functions and returned by value, which copies all members. C does not define ==, < or arithmetic on structures, so a == b is a compile error. To compare structures you compare the members one by one; memcmp is unreliable because padding bytes may hold different values.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.