Passing a pointer to a struct as an argument to a function (void process(struct Data *ptr)) is preferred over passing by value because:
Passing a pointer to a struct as an argument to a function (void process(struct Data *ptr)) is preferred over passing by value because:
Multiple Choice Options
- A✓ Correct Option
It avoids copying large structure byte contents and enables direct modification of the original structure
- B
Structures cannot be passed by value in C
- C
It automatically converts the struct into a union
- D
It forces the struct to reside in CPU cache registers
Detailed Technical Solution & Explanation
Passing a structure pointer passes only the memory address (typically 8 bytes on 64-bit systems), avoiding costly memory copy operations for large structs and enabling the callee to modify the caller's structure directly.