Const array design
One-dimensional lookup
const uint8 CURVE[] = { 0, 3, 7, 13, 22, 35, 52, 72, 100 };
int index;
int output;
main {
index = 5;
if(index >= 0 && index < sizeof(CURVE)) {
output = CURVE[index];
}
}Two-dimensional records
const int16 PROFILES[][] = {
{ 10, 20, 30, 40 },
{ 15, 25, 35, 45 },
{ 20, 30, 40, 50 }
};
int profile;
int point;
int value;
main {
profile = 1;
point = 2;
value = PROFILES[profile][point];
}Choose the narrowest correct type
Last updated

