|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Look-Up Table
Would this concept be valid:
table(1)=5; i=1 j=0 j=table(i); "J"should return 5. In BASIC, I would have to set the start to be 0, use a dim to se ther range to X. Is this necessary in C? Thanks In Advance Last edited by amateurrobotguy : 02-03-2005 at 19:11. |
|
#2
|
||||
|
||||
|
Quote:
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?
}
|
|
#3
|
||||
|
||||
|
Re: Look-Up Table
Yes, I believe that was my answer. I assume that I can delacre my array outside all functions and have it available everywhere too. My example would work in Basic(hopefully)
![]() |
|
#4
|
||||
|
||||
|
Re: Look-Up Table
Is this the proper format then for a table:
rom const int table[5]={1, 2, 3, 4, 5}; Will the multiple lines confuse it? |
|
#5
|
||||
|
||||
|
Re: Look-Up Table
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Lookup table generation tool | WillyC | Programming | 12 | 15-02-2004 21:01 |
| 2-3 minute Interview at Pit Table | ben_whly | Chairman's Award | 5 | 01-04-2002 16:00 |
| table corruption... round 2 | Brandon Martus | Announcements | 0 | 18-12-2001 23:57 |
| table corruption | Brandon Martus | Announcements | 2 | 20-11-2001 05:16 |