新建表单
程序代码:#include
#include
#include
struct book
{
FILE *fp;
int num;
char name[30];
char author[30];
int classnum;
char pub[30];
long int time;
float price;
struct book *next;
};
void new_book(struct book *head);
void main()
{
struct book *head=NULL;
int select;
printf("是否建立新的图书表单?1·是\t2·否\n");
scanf("%d",&select);
if(select==1)
new_book(head);
else
{
printf("请导入原有的表单?输入文件名称");
}
}
void new_book(struct book *head)
{
FILE *fp;
struct book *s,*last=NULL;
float x;
if((fp=fopen("book.txt","wb"))==NULL)
{
printf("创立表单失败");
exit(0);
}
do
{
printf("输入书号");
scanf("%d",&s->num);
getchar();
if(s->num!=1)
{
printf("输入书名");
gets(s->name);
printf("输入作者");
gets(s->author);
printf("输入分类号");
scanf("%d",s->classnum);
getchar();
printf("输入出版社");
gets(s->pub);
printf("输入出版时间");
scanf("%d",s->time);
getchar();
printf("输入价格");
scanf("%f",&s->price);
getchar();
s->next=NULL;
if(head==NULL)
{
head=s;
last=s;
}
else
{
last->next=s;
last=s;
}
fwrite(&s,sizeof(book),1,fp);
}
else
break;
}while(1);
}两个问题1。为什么编译的时候会提示error C2065: 'exit' : undeclared identifier
2.我把exit(0);这一句删了后可以编译链接,运行程序后
运行到输入书号这一步
当我输入一个书号后,就会跳出一个框 unhandled exception in txst..exe:0x0000005:access violation
点击确定后就回去弹出一个标题为find source的文件选择框
然后 没然后了 不知道怎么办了








