Thread: Look-Up Table
View Single Post
  #2   Spotlight this post!  
Unread 02-03-2005, 19:47
ace123's Avatar
ace123 ace123 is offline
Registered User
AKA: Patrick Horn
FRC #0008 (Paly Robotics - http://robotics.paly.net/)
Team Role: Programmer
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Palo Alto, CA
Posts: 50
ace123 has a spectacular aura aboutace123 has a spectacular aura about
Send a message via AIM to ace123
Question Re: Look-Up Table

Quote:
Originally Posted by amateurrobotguy
table(1)=5;

i=1
j=0

j=table(i);

"J"should return 5.
Could you please give more detailed examples next time?
At least show all variable declarations and functions with the important algorithm chopped off.
I'm sorry, but the code pieces you show aren't detailed enough (they don't show types or declarations -- just use bogus numbers or something)

I assume what you have in the code is something like:
Code:
/* Make sure to initialize your array. */
/* int variable[LENGTH]={val1,val2,val3,...} */
int table[10]={3,2,1,6,5,4,9,8,7,0};

void myfunction (void) {
    int i=1;
    int j=0;
    j=table[i]; // Will give you "2", not "3": indicies start at 0, not 1
    // Was that your question?
}
__________________
-Patrick Horn, Paly Robotics

Check out the space simulator called Vega Strike, modelled after the space simulator games Elite and Wing Commander. It's Open Source too!
If you have ever played Wing Commander, or especially Privateer, and had a feeling of nostalga derived from the you will enjoy these two Vega Strike mods: Privateer Gemini Gold and Privateer Remake!
I'm working on adding multiplayer support this year...