View Single Post
  #14   Spotlight this post!  
Unread 01-11-2005, 06:28
MikeDubreuil's Avatar
MikeDubreuil MikeDubreuil is offline
Carpe diem
FRC #0125 (Nu-Trons)
Team Role: Engineer
 
Join Date: Jan 2003
Rookie Year: 1999
Location: Boston, MA
Posts: 967
MikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond reputeMikeDubreuil has a reputation beyond repute
Send a message via AIM to MikeDubreuil
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.