View Single Post
  #1   Spotlight this post!  
Unread 01-03-2005, 23:17
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Static Variables

If I want to define a variable inside of a function and want it to be available to all functions in the .c file, will static do it?

Would this work?

void FunctitonWhatever1(void)
{
static int bob=1;
/*Note the static and the =1*/
CallerFuction();
}

void CallerFunction(void)
{
int bill=0;
/*Only need it in this function*/
bill=2+bob;
}
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).