我想创建一个我的结构类型的数组,但它不是按顺序定义的,例如,我可以随机执行array[3] = mystruct_t;
array[5] = mystruct_t
(3
并且5
在运行时由用户输入定义)。我试过:
这是“理想的”,但不能保存空指针:
static struct mystruct_t foo_inputs[SIZE];
所以,我尝试了:
static struct mystruct_t *foo_inputs;
进而:
foo_inputs[x] = NULL;
但我收到警告:
error: incompatible types when assigning to type ‘struct mystruct_t’ from type ‘void *’
实施它的想法?