View Single Post
  #6   Spotlight this post!  
Unread 13-12-2007, 01:01
DanDon's Avatar
DanDon DanDon is offline
ohhh MY god
AKA: Dan Hoizner
FRC #0375 (The Robotic Plague)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Staten Island, NY
Posts: 1,432
DanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond repute
Send a message via ICQ to DanDon Send a message via AIM to DanDon Send a message via MSN to DanDon
Re: How to manipulate a variable value using an array?

Quote:
Originally Posted by amateurrobotguy View Post
I need you to confirm if what I am thinking is correct:

myVar = 1; Establish the "shell" as being = 1
array[1] = &myVar; Let the 1st value of array[] = the address of the "shell"

(*)(array[1]) = 2; the * means modify/check the contents of the address of myVar
printf(*myVar); since the shell wasn't updated, the * is needed to display the contents of the address of myVar since printf(myVar) would return 1
Code:
 (*)(array[1]) = 2;
That would put a '2' in the memory cell pointed to by the address in array[1]. Or in this case....since the address in array[1] is that of myVar, the value of myVar would be 2, so assuming myVar is an int, your code for printing it out would be:

Code:
printf("%d\n",myVar);
Which would print out '2'.
__________________