我想把不确定个数的结构组写入一个数组,这个程序有什么问题? #include <stdlib.h> #include <stdio.h> struct student{ int term; int ID; char lastName[15]; char firstName[15]; char subject[3]; int catalog; char section[3]; }; int main(int argc, char* argv[]) { int size; char fileName; printf("Please enter the name of the input file: "); scanf("%s", &fileName); printf("Please enter the number of the students: "); scanf("%d",&size); struct student* class; FILE *ifp; int i; for (i=0;i<size;i++){ scanf("%d",class[i].term,); scanf("%d",class[i].ID); scanf("%s",class[i].lastName); scanf("%s",class[i].firstName); scanf("%s",class[i].subject); scanf("d%",class[i].catalog); scanf("%s\n",class[i].section); } class=malloc(sizeof(struct student)*size); ifp=fopen(fileName, "w"); if(ifp==NULL){ printf("The input file was not opened\n"); return 1; } fwrite(people,sizeof(struct student)*size,1,ifp); fclose(ifp); return 0; }
求采纳