I want to make an array of my struct type, but it is not defined in sequence, e.g, randomly I can do array[3] = mystruct_t; array[5] = mystruct_t(3 and 5 is defined at run-time by user input). I had tried:
it’s the “ideal”, but can’t hold null-pointers:
static struct mystruct_t foo_inputs[SIZE];
So, I tried:
static struct mystruct_t *foo_inputs;
and then:
foo_inputs[x] = NULL;
But I get an warning:
error: incompatible types when assigning to type ‘struct mystruct_t’ from type ‘void *’
Ideas to implement it?
Combine the two. In the first, you can’t (shouldn’t) assign
NULLto a non-pointer. In the second, you have one uninitialized pointer. What you want is an array of pointers: