指针指向不完整的类类型
allocteSpace(struct Theacher*** teacherpArray) {struct Theacher** ts = malloc(sizeof(struct Teacher*) * 3);
for (int i = 0; i < 3; i++) {
ts= malloc(sizeof(struct Teacher)); // 下面的 ts 全部报错是怎么回事?
ts->name = malloc(sizeof(char) * 32);
sprintf(ts->name, "Teacher_%d", i + 1);
ts->students = malloc(sizeof(char*) * 4);
for (int j = 0; j < 4; j++) {
ts->students = malloc(sizeof(char) * 32);
sprintf(ts->students, "%s_students_%d", j + 1);
}
}
*teacherpArray = ts;
}
第二个到第六个 ts 全部报错,说 不允许指针指向不完整的类类型“struct Theacher”
谁来帮帮忙,编译器是VS2019 代码是看视频抄来的,看视频老师用的是vs2013d的编译器,可以正常运行 已经找到问题了 {:5_109:}
页:
[1]