制作英汉词典 求大神帮助 帮我看一下这个程序中 E和C 两个数组有没有问题怎么修改
/************2017.7.5上午***********//*制作简单的英汉电子词典*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char A[100][20];
char E[100][20];//英文
char C[100][20];//中文
int count;
int display();
void search();
void modify();
void quit();
void Search_China();
void Search_English();
int showmenu()
{
int choice;
printf("\t\t\t\t*********************************\n");
printf("\t\t\t\t|*********英汉电子词典**********|\n");
printf("\t\t\t\t|*******************************|\n");
printf("\t\t\t\t|***********功能选择************|\n");
printf("\t\t\t\t| 1.显示所有单词 |\n");
printf("\t\t\t\t| 2.查询单词 |\n");
printf("\t\t\t\t| 3.词条修改 |\n");
printf("\t\t\t\t| 4.退出程序 |\n");
printf("\t\t\t\t*********************************\n");
printf("输入你的选择(1-4):");
}
int main()
{
int choice;
while(1)
{
system("cls");
showmenu();
scanf("%d",&choice);
switch(choice)
{
case 1:system("cls");display();break;
case 2:system("cls");search();break;
case 3:system("cls");modify();break;
case 4:system("cls");quit();exit(0);
}
}
}
int display()
{
FILE *fp;
int len,j=0,k,i = 0;
int select;
if ((fp = fopen("C:\\Users\\10028\\Desktop\\实训\\7.6\\day4发学生\\上午\\dictionary.txt", "r")) == NULL)
{
printf("文件1.txt不存在\n");
}
while (fscanf(fp, "%s", A[i]) != EOF)
puts(A[i++]);
count=i-1;//计数
fclose(fp);
for(k=0;k<count;k++)
{
for(i=0;A[k][i]!=',';i++)
{
E[k][i]=A[k][i];
}
} //把英文放入E
for(k=0;k<count;k++)
{
len=strlen(E[k]);
j=0;
for(i=len+1;A[k][i]!='\0';i++)
{
C[k][j]=A[k][i];
j++;
}
}//把中文放入C
printf("按任意键返回\n");
system("pause");
}
void search()
{
int Choice;
system("cls");
printf("\t\t\t\t 【**********1、按中文查找 **********】\n\n");
printf("\t\t\t\t 【**********2、按英文查找 **********】\n\n");
printf("\t\t\t\t 选择 : ");
scanf("%d",&Choice);
if(Choice==1)
Search_China();
else if(Choice==2)
Search_English();
}
void Search_China()
{
int i,flag=1;
char s[20]={0};
char judge;
system("cls");
printf("\n\n\n\n\n\t\t\t\t 输入你所要查询的中文 : ");
scanf("%s",s);
for(i=0;i<count;i++)
{
if(strcmp(s,C[i])==0)
{
printf("\n\n");
printf("\t\t\t\t****************************************\n");
printf("\t\t\t\t##************* 所查如下 *************##\n");
printf("\n\t\t\t\t\t中文 : %s 英文 : %s \n\n",C[i],E[i] );
printf("\t\t\t\t****************************************\n");
flag=0;
}
}
if(flag=1)
printf("\n\t\t\t\t 没有该词条 \n");
printf("是否需要继续查询:(Y/N)");
do
{
judge=getchar();
}while(judge!='Y'&&judge!='y'&&judge!='N'&&judge!='n');
if(judge=='y'||judge=='Y')
search(); //返回查询
}
void Search_English()
{
int i,flag=1;
char s[20]={0};
char judge;
system("cls");
printf("\n\n\n\n\n\t\t\t\t 输入你所要查询的英文 : ");
scanf("%s",s);
for(i=0;i<count;i++)
{
if(strcmp(s,E[i])==0)
{
printf("\n\n");
printf("\t\t\t\t########################################\n");
printf("\t\t\t\t##************* 所查如下 *************##\n");
printf("\n\t\t\t\t\t中文 : %s 英文 : %s \n\n",C[i],E[i]);
printf("\t\t\t\t########################################\n");
flag=0;
}
}
if(flag=1)
printf("\n\t\t\t\t 没有该词条 \n");
printf("是否需要继续查询:(Y/N)");
do
{
judge=getchar();
}while(judge!='Y'&&judge!='y'&&judge!='N'&&judge!='n');
if(judge=='y'||judge=='Y')
search(); //返回查询
}
void modify()
{
int i,k;
char x[200];
char y[20];
char judge;
FILE *fp;
printf("\n请输入要修改的单词的英文:");
scanf("%s",x);
if(strcmp(x,E[i])==0)
{
printf("输入修改后的信息:");
scanf("%s",y);
strcpy(E[i],y);
fp = fopen("C:\\Users\\10028\\Desktop\\实训\\7.6\\day4发学生\\上午\\dictionary.txt", "w");
fscanf(fp, "%s", E[i]);
fclose(fp);
}
do
{
judge=getchar();
}while(judge!='Y'&&judge!='y'&&judge!='N'&&judge!='n');
if(judge=='y'||judge=='Y')
modify(); //返回修改
}
void quit()
{
printf("\t\t\t\t********************************************\n");
printf("\t\t\t\t* *\n");
printf("\t\t\t\t********* 谢谢使用! **********\n");
printf("\t\t\t\t* *\n");
printf("\t\t\t\t********************************************\n");
}