修改一个图书管理系统的程序,用VC写的,没有错误只有警告但是运行不了
#include<stdio.h>#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include<math.h>
struct yx
{
int num[10];
char name[10];
char author[10];
int amount[4];
};
void yxxx();
void yxxt();
void informationmenu();
void checkmenu();
int mainmenu()
{
system("cls");
printf("*******************************************\n");
printf("欢迎来到英雄联盟!\n\n");
printf("\t\t 1.英雄信息系统\n\n");
printf("\t\t 2.退出英雄系统\n\n");
printf("*******************************************\n");
printf("选择\n");
return 0;
}
void informationtable()
{
system("cls");
printf("欢迎来到英雄联盟!\n");
printf("*******************************************\n");
printf("\t\t1.英雄信息录入\n");
printf("\t\t2.英雄信息检查\n");
printf("\t\t3.英雄信息记录\n");
printf("\t\t4.返回到主菜单\n");
printf("*******************************************\n");
}
void checktable()
{
system("cls");
printf("欢迎来到英雄联盟!\n");
printf("*******************************************\n");
printf("\t\t1.英雄编号\n");
printf("\t\t2.英雄名字\n");
printf("\t\t3.英雄类型\n");
printf("\t\t4.返回到英雄信息界面\n");
printf("*******************************************\n");
}
void main1()
{
char choose;
mainmenu();
scanf("%c",&choose);
switch(choose)
{
case'1':yxxx();break;
case'2':system("cls");
printf("\n\n\n\n\n\n\n\n\n\t\t\t 再见....");
getch();
exit(0);
}
}
void yxxx()
{
char choose;
informationmenu();
}
void yxin();
void checkyx();
void check();
void tj();
main()
{
main1();
getch();
}
void informationmenu()
{
char choose;
informationtable();
printf("请选择一个选项! :");
scanf("%c",&choose);
switch(choose)
{
case'1':yxin();break;
case'2':checkyx();break;
case'3':tj();break;
case'4':mainmenu();
}
}
void checkyx()
{
char choose;
checkmenu();
}
void checkmenu()
{
char choose;
checktable();
check();
}
void yxin()
{
char num1[10];
char name1[20];
char author1[10];
char ch;
int amount1[4];
struct yx temp;
FILE*fp;
printf("\n\n欢迎添加一个英雄!");
/*if((fp)==NULL)
{
printf("THE FILE DOSEN'T EXIST!!!");
fp=fopen("D:\\yxin.txt","w");
fclose(fp);
}*/
fp=fopen("D:\\yxin.txt","w+");
ch='y';
do{
printf("\n\n输入一个新英雄(number;yxname;author;amount;)\n\n");
scanf("%s %s %s %s",num1,name1,author1,amount1);
fprintf(fp,"%s %s %s %s",temp.num,temp.name,temp.author,temp.amount);
printf("输入y继续录入");
ch=getch();
}
while(ch=='y');
fclose(fp);
printf("\n储存成功!!!\n");
printf("");
}
int yxsj()
{
FILE*fp;
int tnum=0,tamount=0,n;
char tname[20]={'\0'},tauthor[20]={'\n'};
fp=fopen("D:\\yxin","rb");
for(n=0;!feof(fp);n++)
fscanf(fp,"%s %s %s %s",&tnum,tname,tauthor,&tamount);
n--;
fclose(fp);
return(n);
}
void check()
{
FILE*fp;
char choose;
int tnum=0,ttnum=0,tamount=0,k,i,l,c;
char tname[20]={'\n'},ttname[20]={'\0'},tauthor[20]={'\0'},ttauthor[20]={'\0'};
if((fp=fopen("D:\\yxin","rb"))==NULL)
{
printf("\n\n\n\n\n\n\n\n\n\t\t\t文件没有被找到!任意键返回.");
getch();
informationtable();
}
l=yxsj();
checktable();
scanf("%c",&choose);
if(choose=='4')
informationtable();
else if(choose=='1')
{
system("cls");
printf("输入英雄编号:");
scanf("%s",ttnum);
}
else if(choose=='2')
{
system("cls");
printf("输入英雄名字:");
scanf("%s",ttname);
}
else if(choose=='3')
{
system("cls");
printf("输入英雄类型:");
scanf("%s",ttauthor);
}
system("cls");
for (i=0;i<1;i++)
{
fscanf(fp,"%s%s%s%s",tnum,tname,tauthor,tamount);
k==(!strcmp(ttnum,tnum)||!strcmp(ttname,tname)||!strcmp(ttauthor,tauthor));
if(k!=0)
{
printf("\t\t\t\t搜索结果:\n\n");
printf("\tyxnum\t\tyxname\tyxauther\tyxamount \n");
printf("\t%s\t\t%s\t\t%s\t\t%s\n",tnum,tname,tauthor,tamount);
printf("\n\t\t你确定是这个英雄?(YorN)\n\n");
scanf("%c",c);
if(c=='Y')tamount--;
printf("\t\t现有英雄数量是\t%s",tamount);
}
if(k==0)
{
system("cls");
printf("\n\n\n\n\n\n\n\t\t\t\t一个也没有!\n");
getch();
yxxx();
}
}
fclose(fp);
getch();
yxxx();
}