← Quiz: Structures and Unions: all 10 questions
Quiz: Structures and Unions · Question 10 of 10
Why do functions usually take a pointer to a large struct, like void show(const struct Student s), rather than the stru…
Why do functions usually take a pointer to a large struct, like void show(const struct Student *s), rather than the struct itself?
- A.Structs cannot be passed to functions by value
- B.Passing by value copies the whole struct; a pointer passes only an address
- C.Pointers make the members public
- D.It is required by the -> operator
Answer & explanation
Correct answer: Passing by value copies the whole struct; a pointer passes only an address
const keeps the function from changing the caller's struct while avoiding the copy.
Can you get the rest right without peeking?
Take the timed Quiz: Structures and Unions quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →