我遇到以下指向 void 变量的双指针错误void ** foo。尽管我正在转换结构类型,但我不明白为什么会收到此错误。现在不应该*heap->foo[0]包含/指向 的地址吗personA?
typedef struct Person{
char * name;
char age;
}Person;
typedef struct myStruct{
void ** foo;
}myStruct;
void initialize(myStruct * H, int numbOfPersons){
H->foo = malloc(sizeof(myStruct*));
*H->foo = malloc(sizeof(myStruct)*numberOfPersons);
}
void insert(myStruct * H, void * personA){
*H->foo[0] = (myStruct)personA; //error here
}
int main(void){
myStruct heap;
int numberOfPpl = 2;
initialize(heap, numberOfPpl);
Person A;
A.grade = 10
strcpy(A->name, "Jason");
Insert(&heap, &A);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
incomplete type 'void' …Run Code Online (Sandbox Code Playgroud)