View Single Post
  #5   Spotlight this post!  
Unread 13-12-2007, 01:54
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
Re: How to manipulate a variable value using an array?

So i have to say that my array of buttons is going to be holding addresses by declaring it like this:
Code:
int (*)joystickbuttons[8] = {&p1_sw_trig, &p1_sw_top, &pl_sw_aux1, &p1_sw_aux2, &p2_sw_trig, &p2_sw_top, &p2_sw_aux1, &p2_sw_aux2};
And thus the * in the declaration indicates that the variable is "special" in that it will indeed be holiding addresses and not just numbers and crap.

And the 2nd half of the above code:
Code:
if ((*)joystickbuttons[arrayindexer[1]] == 1)
Will my above 2 pieces of code work?

I don't get some of your example:

Code:
void idouble(int * input){  Input the address and convert it to the data "input"
   *input += input ; I don't get the use of *input
}

void main(){
    int x ;
    x = 5 ;
    idouble(&x) ;  Call the above function giving it an address as a parameter
    print(x); I don't get how the idouble() returns x
}
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).

Last edited by amateurrobotguy : 13-12-2007 at 02:11.