谁能帮忙看下下面的代码错哪了
#include<stdio.h>#include<stdlib.h>
main()
{
struct film
{int i;
struct film *next;
};//链表输入数据
struct film *head,*last,*ptr;
head=last=(struct film*) malloc(sizeof(struct film));
int i;
while(scanf("%d",&i))
{
ptr=(struct film*) malloc(sizeof(struct film));
last->next=ptr;
last=ptr;
last->i=i;
}//下面是查找链表中大于8的数删除;
struct film *p,*f;
p=head;
f=head->next;
while(f)
{ if(f->i>8)
{if(f->next==NULL)
{p->next=NULL;
free(f);}
else
{p->next=f->next;
free(f);}}
p=f;
f=f->next;
}
//下面是输出;
ptr=head->next;
while(ptr)
{
printf("%d",ptr->i);
ptr=ptr->next;
}//下面清空
ptr=head;
while(ptr)
{ptr=head->next;
free(head);
head=ptr;
}
}