C - initialize array of structs

前端 未结 4 712
情歌与酒
情歌与酒 2020-12-14 18:49

I am having a problem initializing an array of structs. I\'m not sure if I am doing it right because I get \"initialization from incompatible pointer type\" & \"assignme

4条回答
  •  被撕碎了的回忆
    2020-12-14 19:43

    When initializing, shoudn't it be like this?

    student** students = (struct student**)malloc(sizeof(student*)*numStudents);
    

    However, why pointer to a pointer? Just with a pointer to struct is enough I think.

提交回复
热议问题