|
Re: Typedef Struct as function input
Quote:
|
Originally Posted by BorisTheBlade
just curious as to why you would want to do that? I don't see why you would ever want to do that. I mean the whole point of a structure is you can access it from anywhere or create a new structure in any function in your program.
|
The point of a structure is to keep a common set of variables grouped together. For instance you could create a structure for a robot's arm, with a variable for the motor and the sensor monitoring the angle.
One concept of "good programming technique" is to keep the variable's scope so that only functions that require access to it are able to. Structures are variables and this rule applies. In general you want to try to keep as few globals as possible. Instead, declare a variable static in a function; that will keep the value of the variable after it is removed from the stack (gone to a different function.)
__________________
"FIRST is like bling bling for the brain." - Woodie Flowers
Last edited by MikeDubreuil : 01-11-2005 at 06:31.
|