2 ms·
Arrays of anonymous structs are also useful for non-global data: static struct { const char *key; const char *value; } elems[] = {
by nwellnhof 6y ago
Arrays of anonymous structs are also useful for non-global data:
static struct {
const char *key;
const char *value;
} elems[] = {
{ "k1", "v1" },
{ "k2", "v2" },
{ "k3", "v3" }
};
for (int i=0; i<sizeof(elems)/sizeof(*elems); i++) {
printf("%s => %s\n", elems[i].key, elems[i].value);
}