This preview shows pages 28–29. Sign up to view the full content.
It is legal to pass a structure variable as an argument to a function, but it is rarely the best option.`If the structure is large, because parameters are passed by value in C, all of the values of the members in the structure will have to be copied and pushed onto the stack when the function is called.`On the other hand, if we pass a pointer to the structure as a parameter, then only the value of the pointer is passed, and pushed onto the stack, rather than copies of all the values in the structure.`The price for this is that dereferencing must be used inside of the function in order to access the structure members (a small price for the storage space saved, and the speed up in execution time).`Therefore, only structures which are not much larger than a pointershould be passed directly.
has intentionally blurred sections.
Sign up to view the full version.