I really hope this isn’t one of those super basic questions.
Anyway, I’ve got a struct with 47 components, and I’m calling various functions that use anywhere from 3 to 10 of these components at once.
Is it better to call the function like:
foo(pParam->variable1, pParam->variable2, pParam->variable3)
or foo(pParam) and then in the function use pParam->variable1; pParam->variable2; pParam->variable3; ?
Thanks in advance!
You should pass the struct by reference, that way you don’t need to copy all the values:
In general structures are there so you can unite data. So it doesn’t make sense to take it apart and pass different parameters to functions.
It should stay as a single unit.