I have a struct
Code:
typedef struct
{
char *name;
float value;
void *pntr;
uint8_t found;
}DICTIONARY;
Initialize it
Code:
static DICTIONARY pid_dict[] =
{
{"-p" , 0, 0, 0 },
{"-i" , 0, 0, 0 },
{"-d" , 0, 0, 0 },
{"-max", 0, 0, 0 },
{"-min", 0, 0, 0 },
{"-var", 0, 0, 0 },
};
Function to work with the struct
Code:
uint32_t ParseDictionary(DICTIONARY *dict[], char** args, uint32_t argc)
{
uint32_t dict_len = (sizeof (dict)/sizeof (dict[0]));
uint32_t i, j;
float val;
for (i = 0; i < argc; i++)
{
for (j = 0; j < dict_len; j++)
{
if (strcmp(args[i], dict[j]->name)==0)
{
if (IsFloat(args[i+1]))
{
val = atof(args[i+1]);
dict[j]->value = val;
dict[j]->found = 1;
}
else
return MSG_INV_ARG;
}
}
}
return MSG_OK;
}
Now I want to pass it to a function
Code:
ParseDictionary(&pid_dict, &args[1], argc);
I get - Error[Pe167]: argument of type "DICTIONARY (*)[6]" is incompatible with parameter of type "DICTIONARY **"
And this way
Code:
ParseDictionary(&pid_dict[0], &args[1], argc);
I get -Error[Pe167]: argument of type "DICTIONARY *" is incompatible with parameter of type "DICTIONARY **"
What is wrong?