[LCP]passing struct to function
Greg Black
gjb at gbch.net
Mon Nov 22 04:01:01 UTC 2004
On 2004-11-21, Carlos Pruitt, Jr. wrote:
> Thanks to everyone who replied. It makes perfect sense now. I am
> almost halfway through Oreilly's Practical C Programming. This is the
> first real problem I have had. It looks like I attempted to do a
> mixture of both methods :P
>
> As Greg pointed out I could have simply passed the address of my list to
> the function or I could have declared a pointer, assigned the address of
> my list to the pointer, then passed the pointer (not address to the
> pointer) to the function. I have tested both methods and they work fine.
>
> Which of the two methods is preferred in the industry? Or does it
> really matter, as long as I am consistant?
There's no point in declaring an extra variable for this purpose
in this sort of program. That's why my solution removed the
extra variable. In general, anything that reduces complexity is
good; extra variables add complexity (to a small degree), and so
are best avoided.
Greg
More information about the linuxCprogramming
mailing list