链表修改了很多回,可还是错误
程序代码:#include<stdio.h>
#include<string.h>
#include<malloc.h>
struct book
{
int num;
char name[30];
char author[30];
int classnum;
char pub[30];
long int time;
float price;
struct book *next;
};
void main()
{
struct book *last,*head,*s;
int x=1;
float y;
head=NULL;
last=NULL;
while(x==1)
{
struct book *s;
s=(struct book*)malloc(sizeof(struct book));
printf("请输入书号");
scanf("%d",&s->num);
printf("输入书名");
gets(s->name);
printf("输入作者");
gets(s->author);
printf("输入分类号");
scanf("%d",&s->classnum);
printf("输入出版社");
gets(s->pub);
printf("输入出版时间");
scanf("%d",&s->time);
printf("输入价格");
scanf("%f",&y);
s->price=y;
s->next=NULL;
last->next=s;
last=s;
printf("是否继续\n1·是\n2·否\n");
scanf("%d",&x);
}
}编译链接都没问题,就是运行程序时 当输入完价格就出错,调试器指着 last->next=s; 是这句语句错了吗?恕我眼搓 找不出错误啊
请各位大大帮我看看









