I would like to calculate the number of element of the array using the following c code :
#include <stdio.h>
// Number of elements in an array
#define NUM_ELEM(x) (sizeof((x)) / sizeof((x)[0]))
#define LIST_KEY (char *[])
typedef struct dm_key_reg {
char *obj;
char **ukey;
}DMKEYREG;
DMKEYREG tab_reg_key[]={
{"Device_SS", LIST_KEY{"SerialSS", "SSS", "A"}},
{"Device__AP", LIST_KEY{"SerialAP", "III", "B"}},
{"Device___EP", LIST_KEY{ "SerialEP", "EEE", "CCC", "C"}},
{0}
};
int main(void)
{
int i=0;
DMKEYREG *tab_key = tab_reg_key;
for (; tab_key->obj; tab_key++) {
i++;
printf("i=%d <> ukeysize= %d\n",i, NUM_ELEM((tab_reg_key->ukey)));
}
}
but I got the following result:
i=1 <> ukeysize= 1
i=2 <> ukeysize= 1
i=3 <> ukeysize= 1