链表数据读取问题
程序代码:
//头文件 #ifndef _HEAD_ #define _HEAD_ #define NSIZE 45 struct film{ char title[NSIZE]; //用于存放电影名 int rating; //评分 }; typedef struct film Film; struct node{ Film item; struct node *next; //指向下一节点的指针 }; typedef struct node NODE; typedef NODE* LIST; void initialization (LIST *pfile); //初始化链表 bool listisfull(void); //没什么用 void additem(LIST* pfile,Film list); //向链表尾部添加数据 void cleanlist(LIST *pfile); //释放链表 void copystr(Film film,LIST pfile); //将数据存入节点 int showlist(LIST pfile); //显示数据 #endif //主函数 #include<stdio.h> #include<stdlib.h> #include"head.h" int main(void) { Film list; LIST movies; initialization (&movies); //初始化 printf("please enter the title of movie\n"); while((gets(list.title)!=0)&&(list.title[0]!='\0')) { puts("enter your grade(0~10)"); scanf("%d",&list.rating); while(getchar()!='\n') continue; additem(&movies,list); listisfull(); puts("enter the title of the next film"); } showlist(movies); cleanlist(&movies); puts("bye~"); return 0; } void initialization (LIST *pfile) { *pfile=NULL; } bool listisfull(void) { LIST p; p=(LIST)malloc(sizeof(node)); if(p==NULL) { fprintf(stderr,"the list is already full\n"); exit(1); } return false; } void additem(LIST* pfile,Film list) { if(*pfile==NULL) { *pfile=(LIST)malloc(sizeof(node)); copystr(list,*pfile); (*pfile)->next=NULL; } else { LIST p; p=*pfile; while(p!=NULL) p=p->next; copystr(list,p); p->next=NULL; } } void cleanlist(LIST *pfile) { LIST p; while(*pfile!=NULL) { p=(*pfile)->next; free(*pfile); *pfile=p; } puts("clean up!"); } int showlist(LIST pfile) { int count=0; while(pfile!=NULL) { count++; printf("%2d:%45s %2d\n",count,pfile->item->title,pfile->item->rating); //问题出在printf这里,编译器一直报错。具体报错在最后 pfile=pfile->next; } return count; } void copystr(Film film,LIST pfile) { pfile->item=film; }
[Error] base operand of '->' has non-pointer type 'Film {aka film}'
[Error] base operand of '->' has non-pointer type 'Film {aka film}'
请问是哪里不对,编译器的报错看不明白