gpt4 book ai didi

c - 不完整类型 'void' 不可分配 c

转载 作者:太空宇宙 更新时间:2023-11-04 01:24:27 24 4
gpt4 key购买 nike

<分区>

我遇到以下指向 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;
}

我收到以下错误:

incomplete type 'void' is not assignable
*H->foo[0] = (Student*)I;

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com