一份课程设计 编译没有错 调试出现link。exe错误求助
#include<stdio.h> //??????#include<string.h> //????????
#include<stdlib.h>
#include<conio.h> //????
#include<malloc.h> //????
#define MAXNAME 11 //??????
#define MAXwriter 21
#define MENU_COUNT 5 //??????
#define MAXN 15
//???????fi_type,????????
typedef enum _fi_type
{
news=1, //????
}fi_type;
//???????
struct fi_info
{char name[MAXNAME];
char writer[MAXwriter];
int typenum;
char publish_from[MAXN];
int publish_time;
float price;
fi_type type;
struct fi_info* next; //???????,??????????????
};
struct fi_info *head=NULL,*head_=NULL ; //?????????,???????
int Book_num; //????????
void menu();
int ReadinfoFromFile(); //????
//????
int creat_news();
void search_news();
void delete_news();
void update_news();
void show();
void quit();
int main()
{
int selected=0,land_num; //??????
ReadinfoFromFile();//????
printf("??????????????:");
scanf("%d",&land_num);
while(selected>=0&&selected<=MENU_COUNT)
{
system("cls"); //??
menu(); //?????
printf(">?????????(%d_%d):",0,MENU_COUNT);
if(scanf("%d",&selected)!=1||selected<0||selected>MENU_COUNT)
{
printf(">????!???(%d-%d)?????!??????...",0,MENU_COUNT);
fflush(stdin); //???????
getchar();
}
else
{
switch(selected)
{
case 1:creat_news();break;
case 2:search_news();break;
case 3:delete_news();break;
case 4:update_news();break;
case 5:show();break;
case 0:quit();
}
}
selected=0;
}
return 0;
}
int ReadinfoFromFile() //????
{
FILE *fp=NULL; //????
struct fi_info *p=NULL; //?????
int i;
if((fp=fopen("sun.txt","r+"))==NULL)
{
printf("?????!\n");
fp=fopen("sun.txt","w"); //?????????
printf("??????!\n");
}
fscanf(fp,"%d",&Book_num); ////???????????????,?????for???????
for(i=0;i<Book_num;i++){
p=(struct fi_info*)malloc(sizeof(struct fi_info)); //P?????,??????
fscanf(fp,"%s",p->name);
fscanf(fp,"%s",p->writer);
fscanf(fp,"%d",&p->typenum);
fscanf(fp,"%s",p->publish_from);
fscanf(fp,"%d",&p->publish_time);
fscanf(fp,"%f",&p->price);
fscanf(fp,"%d",&p->type);
if(p->type==1)
{
if(head==NULL){
head=p;
p->next=NULL;
}
else{
p->next=head;
head=p;
}
}
else{
if(head_==NULL){
head_=p;
p->next=NULL;
}
else{
p->next=head_;
head_=p;
}
}
}
fclose(fp);
return 0;
}
void menu(){
printf("\n\n*******************************????????********************************\n");
printf("\t\t\t 1;??????\n");
printf("\t\t\t 2;??????\n");
printf("\t\t\t 3;??????\n");
printf("\t\t\t 4;??????\n");
printf("\t\t\t 5;??????\n");
printf("\t\t\t 0;?? \n");
}
int creat_news() //??????
{
struct fi_info *p=NULL;
p=(struct fi_info*)malloc(sizeof(struct fi_info));
printf("?????:");
scanf("%s",p->name);
printf("??????:");
scanf("%s",p->writer);
printf("??????:");
scanf("%d",&p->typenum);
printf("???????:");
scanf("%s",p->publish_from);
printf("???????:");
scanf("%d",&p->publish_time);
printf("???????:");
scanf("%f",&p->price);
p->type=news;
Book_num+=1;
p->next=head;
head=p;
return 0;
}
void search_news() //??????
{
struct fi_info *p=NULL;
char name[10],writer[21];
int price;
int b=1,i;
printf("???????1.\n????????2.\n???????3.\n");
scanf("%d",&i);
if(i=1)
{
printf("?????????:");
scanf("%s",name);
for(p=head;p!=NULL;p=p->next) //??????p???,????p==NULL
{
if(strcmp(name,p->name)==0) //????????,????????0
{ b=0; //???,?b=0
printf("????????????:\n");
printf("%s\n",p->name);
printf("%s\n",p->writer);
printf("%d\n",p->typenum);
printf("%s\n",p->publish_from);
printf("%d\n",p->publish_time);
printf("%f\n",p->price);
}
}
if(head==NULL) printf("???????\n");
if(b) printf("????????????!\n"); //?b=1,????
}
else if(i=2)
{
printf("??????????:");
scanf("%s",writer);
for(p=head;p!=NULL;p=p->next) //??????p???,????p==NULL
{
if(strcmp(writer,p->writer)==0) //????????,????????0
{ b=0; //???,?b=0
printf("????????????:\n");
printf("%s\n",p->name);
printf("%s\n",p->writer);
printf("%d\n",p->typenum);
printf("%s\n",p->publish_from);
printf("%d\n",p->publish_time);
printf("%f\n",p->price);
}
}
if(head==NULL) printf("???????\n");
if(b) printf("????????????!\n"); //?b=1,????
}
else if(i=3)
{
printf("??????? ?? ??\n:");
scanf("%s %d",name,&price);
for(p=head;p!=NULL;p=p->next) //??????p???,????p==NULL
{
if(strcmp(name,p->name)==0&&price==p->price) //????????,????????0
{ b=0; //???,?b=0
printf("????????????:\n");
printf("%s\n",p->name);
printf("%s\n",p->writer);
printf("%d\n",p->typenum);
printf("%s\n",p->publish_from);
printf("%d\n",p->publish_time);
printf("%f\n",p->price);
}
}
if(head==NULL) printf("???????\n");
if(b) printf("????????????!\n"); //?b=1,????
} else printf("??:???????,?????:\n");
system("PAUSE"); //??
}
void delete_news() //??????
{
struct fi_info *p=NULL; //?????????
struct fi_info *q=NULL;
char name[10];
int b=1;
int a;
printf("?????????:\n");
scanf("%s",name);
for(p=head,q=head;p!=NULL;p=p->next)
{
if(strcmp(name,p->name)==0)
{
b=0;
printf("????? 0(?) or 1(?)\n");
scanf("%d",&a);
if(a==0)
{
if(p==head)
head=head->next;
else
q->next=p->next;
printf("????!\n");
}
}
else q=p;
}
if(b) printf("??:???????\n");
system("PAUSE");
}
void update_news() //??????
{
struct fi_info *p=NULL;
int a,b=1;
char name[10];
printf("?????:\n\n");
scanf("%s",name);
for(p=head;p!=NULL;p=p->next)
{
if(strcmp(p->name,name)==0){
b=0;
printf("%s\n",p->name);
printf("%s\n",p->writer);
printf("%d\n",p->typenum);
printf("%s\n",p->publish_from);
printf("%d\n",p->publish_time);
printf("%f\n",p->price);
printf("??????? 0 (?)or 1(?)\n");
scanf("%d",&a);
if(a==0){
printf("**********???????*********\n");
canf("%d",&p->typenum);
printf("???????:");
scanf("%s",&p->publish_from);
printf("???????:");
scanf("%d",&p->publish_time);
printf("???????:");
scanf("%f",&p->price);
p->type=news;
printf("\n\n ??:?????!\n\n");
}
}
if(b==1) printf("?????????!\n");
}
system("PAUSE");
}
void show() //??????
{
struct fi_info *p=NULL;
system("cls");
for(p=head;p!=NULL;p=p->next)
{
printf("%s\n",p->name);
printf("%s\n",p->writer);
printf("%d\n",p->typenum);
printf("%s\n",p->publish_from);
printf("%d\n",p->publish_time);
printf("%f\n",p->price);
system("PAUSE");
}
}
void quit() //???? ?????
{ FILE *fp=NULL;
struct fi_info *p=NULL;
system("cls");
fp=fopen("sun.txt","w");
fprintf(fp,"%d ",Book_num);
for(p=head;p!=NULL;p=p->next)
{ fprintf(fp,"%s ",p->name);
fprintf(fp,"%s\n ",p->writer);
fprintf(fp,"%d ",p->typenum);
fprintf(fp,"%s ",p->publish_from);
fprintf(fp,"%d ",p->publish_time);
fprintf(fp,"%f ",p->price);
fprintf(fp,"%d ",p->type);
}
printf("\n");
printf("?????????????!\n") ;
printf("\n");
fclose(fp);
exit(0);
}