我必须使用以下代码块进行学校作业,严格禁止任何修改.
typedef struct
{
char* firstName;
char* lastName;
int id;
float mark;
}* pStudentRecord;
pStudentRecord* g_ppRecords;
int g_numRecords =0;
Run Code Online (Sandbox Code Playgroud)
这里g_ppRecords应该是一个指向结构的指针数组.什么我完全不理解的是,说明如何能pStudentRecords *g_ppRecords;意味着g_ppRecords是一个数组,因为数组应该被定义为
type arrayname[size];
Run Code Online (Sandbox Code Playgroud)
我尝试动态地为g_ppRecords分配内存,但这没有帮助.
g_ppRecords = (pStudentRecord*) malloc(sizeof(pStudentRecord*)*(g_numRecords+1));
Run Code Online (Sandbox Code Playgroud)