JasonWB007
Programmer
Hi everyone,
Sorry if this is too simple, but I am trying to figure out how to access an array of strings, using an index for the string. I have:
typedef struct
{
PARMTYPE parmtype;
_iq* parmptr;
int num_indices;
const char *(indices[10]);
// const char *indices;
} PARMTAB;
and I want to be able to access an array of strings, such as:
// PD biquad coefficients
#define NUM_PD_COEFF_INDICES COEFFS_PER_BIQUAD*NBIQ*NUM_PID_LOOPS
const char PD_Coeff_Indices[NUM_PD_COEFF_INDICES][MAX_CONTROLPARMINDEXLIST_ITEM_SIZE] =
{
"Speed a2\0", "Speed a1\0", "Speed b2\0", "Speed b1\0", "Speed b0\0",
"Temp a2\0", "Temp a1\0", "Temp b2\0", "Temp b1\0", "Temp b0\0"
};
// Offset all the way into the individual string
// parm_index_ptr = parmtab[parm_index].indices + 10*index;
parm_index_ptr = parmtab[parm_index].indices[index];
The commented ways were the old ones that worked, but I would really like to be able to specify which character array I want by an index, not by a bunch of silly math. Any ideas?
Thanks,
Jason
Sorry if this is too simple, but I am trying to figure out how to access an array of strings, using an index for the string. I have:
typedef struct
{
PARMTYPE parmtype;
_iq* parmptr;
int num_indices;
const char *(indices[10]);
// const char *indices;
} PARMTAB;
and I want to be able to access an array of strings, such as:
// PD biquad coefficients
#define NUM_PD_COEFF_INDICES COEFFS_PER_BIQUAD*NBIQ*NUM_PID_LOOPS
const char PD_Coeff_Indices[NUM_PD_COEFF_INDICES][MAX_CONTROLPARMINDEXLIST_ITEM_SIZE] =
{
"Speed a2\0", "Speed a1\0", "Speed b2\0", "Speed b1\0", "Speed b0\0",
"Temp a2\0", "Temp a1\0", "Temp b2\0", "Temp b1\0", "Temp b0\0"
};
// Offset all the way into the individual string
// parm_index_ptr = parmtab[parm_index].indices + 10*index;
parm_index_ptr = parmtab[parm_index].indices[index];
The commented ways were the old ones that worked, but I would really like to be able to specify which character array I want by an index, not by a bunch of silly math. Any ideas?
Thanks,
Jason