You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
294 lines
6.0 KiB
294 lines
6.0 KiB
#include "stdio.h"
|
|
#include "stdlib.h"
|
|
#include "string.h"
|
|
#include<conio.h>
|
|
#define FILENAME "翻译文档31.txt"
|
|
#define shoucanjia "收藏夹56.txt"
|
|
struct word
|
|
{
|
|
char chinese[100];
|
|
char english[100];
|
|
char mean[100];
|
|
char shuxing[100];
|
|
};
|
|
|
|
|
|
|
|
FILE *FP;
|
|
FILE *fileopen(char FileName[])//打开翻译文档
|
|
{
|
|
FILE *fp;
|
|
if((fp=fopen(FileName,"rb"))==NULL)
|
|
{
|
|
printf("NO");
|
|
}
|
|
fp=fopen(FileName,"ab+");
|
|
}
|
|
|
|
void fileclose(FILE *fp)//关闭翻译文档
|
|
{
|
|
if(fclose(fp)!=NULL)
|
|
{
|
|
printf("close defit");
|
|
}
|
|
}
|
|
|
|
void shoucan(word temp)//收藏的单词
|
|
{
|
|
FP=fileopen(shoucanjia);
|
|
printf("\n%s %s %s %s ",temp.english,temp.chinese,temp.mean,temp.shuxing);
|
|
printf("收藏成功!!!");
|
|
fwrite(&temp,sizeof(temp),1,FP);
|
|
fileclose(FP);
|
|
|
|
}
|
|
|
|
void findlike()//查收藏夹
|
|
{
|
|
system("cls");
|
|
FILE *fp;
|
|
if((fp=fopen(shoucanjia,"r"))==NULL)
|
|
{
|
|
printf("OPEN DEFIT");
|
|
}
|
|
char tempenglish[100];
|
|
for(int z=0;z<=100;z++)
|
|
tempenglish[z]=0;
|
|
char *res;
|
|
word temp;
|
|
int n=0,i=0;
|
|
printf("PLEAES INPUT ENGLISH:");
|
|
printf("输入单词:");
|
|
printf("退格:退格查看所有单词\n");
|
|
while(1)
|
|
{
|
|
int m=0;
|
|
printf("\n\n\n返回上一级按空格键 ");
|
|
if(i!=0)
|
|
printf("退格:退后一个单词");
|
|
char c=getch();
|
|
system("cls");
|
|
if(c==32)
|
|
break;
|
|
printf("输入单词:");
|
|
if(c==8)
|
|
{
|
|
tempenglish[i-1]=0;
|
|
for(int j=0;j<i;j++)
|
|
{
|
|
printf("%c",tempenglish[j]);
|
|
}
|
|
i=i-1;
|
|
}
|
|
else{
|
|
tempenglish[i]=c;
|
|
for(int j=0;j<=i;j++)
|
|
printf("%c",tempenglish[j]);
|
|
i=i+1;
|
|
}
|
|
FILE *fp;
|
|
if((fp=fopen(shoucanjia,"r"))==NULL)
|
|
{
|
|
printf("OPEN DEFIT");
|
|
}
|
|
|
|
while(fread(&temp,sizeof(word),1,fp))
|
|
{
|
|
|
|
|
|
if(strcmp(temp.english,tempenglish)==0)
|
|
{
|
|
printf("\n中文是:%s 英文是:%s 例句是:%s 属性是:%s\n",temp.chinese,temp.english,temp.mean,temp.shuxing);
|
|
n=0;
|
|
}
|
|
else
|
|
{
|
|
char *res = strstr(temp.english,tempenglish);
|
|
if(res == NULL)
|
|
{
|
|
n=2;
|
|
}
|
|
else
|
|
{
|
|
printf("\n你要查找的可能是:\n中文是:%s 英文是:%s 例句是:%s 属性是:%s\n",temp.chinese,temp.english,temp.mean,temp.shuxing);
|
|
m=1;
|
|
}
|
|
}
|
|
}
|
|
fileclose(fp);
|
|
if(n==2&&m==0)
|
|
printf("\nno this");
|
|
}
|
|
fileclose(fp);
|
|
}
|
|
|
|
void change()//翻译
|
|
{
|
|
system("cls");
|
|
char tempenglish[100];
|
|
for(int z=0;z<=100;z++)
|
|
tempenglish[z]=0;
|
|
char *res;
|
|
word temp;
|
|
int n=0,i=0,m=0;
|
|
printf(" 输入单词:");
|
|
printf("退格查看所有单词。");
|
|
while(1)
|
|
{
|
|
m=0;
|
|
printf("\n\n\n返回上一级按空格键 ");
|
|
if(i!=0)
|
|
printf("退格:退后一个单词");
|
|
char c=getch();
|
|
stop: system("cls");
|
|
// if(c==49)
|
|
// {
|
|
// shoucan(temp);//收藏单词;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
// break;
|
|
// }
|
|
if(c==32)
|
|
break;
|
|
printf(" 输入单词:");
|
|
if(c==8)
|
|
{
|
|
tempenglish[i-1]=0;
|
|
for(int j=0;j<i;j++)
|
|
{
|
|
printf("%c",tempenglish[j]);
|
|
}
|
|
i=i-1;
|
|
}
|
|
else{
|
|
tempenglish[i]=c;
|
|
for(int j=0;j<=i;j++)
|
|
printf("%c",tempenglish[j]);
|
|
i=i+1;
|
|
}
|
|
FILE *fp;
|
|
if((fp=fopen(FILENAME,"rb+"))==NULL)
|
|
{
|
|
printf("OPEN DEFIT");
|
|
}
|
|
|
|
while(fread(&temp,sizeof(word),1,fp))
|
|
{
|
|
if(strcmp(temp.english,tempenglish)==0)
|
|
{
|
|
printf("\n中文是:%s 英文是:%s 例句是:%s 属性是:%s\n",temp.chinese,temp.english,temp.mean,temp.shuxing);
|
|
printf("\n-------按1收藏");
|
|
printf("\n-------按0修改");
|
|
printf("\n-------按其他键继续查找");
|
|
c=getch();
|
|
if(c==49)
|
|
{
|
|
shoucan(temp);//收藏单词
|
|
}
|
|
else if(c==48)//修改单词
|
|
{
|
|
// printf("%d",sizeof(word));
|
|
// printf("%s %s %s %s ",temp.english,temp.chinese,temp.mean,temp.shuxing);
|
|
printf("\n修改后的英文:");
|
|
scanf("%s",temp.english);
|
|
printf("修改后的意思:");
|
|
scanf("%s",temp.chinese);
|
|
printf("例子:");
|
|
scanf("%s",temp.mean);
|
|
printf("属性:");
|
|
scanf("%s",temp.shuxing);
|
|
printf("%s %s %s %s ",temp.english,temp.chinese,temp.mean,temp.shuxing);
|
|
// printf("%d",sizeof(word));
|
|
// printf("%d",sizeof(temp));
|
|
fseek(fp,-sizeof(word),SEEK_CUR);
|
|
|
|
fwrite(&temp,sizeof(temp),1,fp);
|
|
printf("修改成功!!!");
|
|
//fileclose(fp);
|
|
break;
|
|
}
|
|
else
|
|
goto stop;
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
char *res = strstr(temp.english,tempenglish);
|
|
if(res != NULL)
|
|
{
|
|
printf("\n你要查找的可能是:\n中文是:%s 英文是:%s 例句是:%s 属性是:%s\n",temp.chinese,temp.english,temp.mean,temp.shuxing);
|
|
m=1;
|
|
}
|
|
else
|
|
{
|
|
n=2;
|
|
}
|
|
}
|
|
}
|
|
fileclose(fp);
|
|
if(n==2&&m==0)
|
|
{
|
|
printf("\nno this");
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void putinto()//插入词库
|
|
{
|
|
stop: printf("\n");
|
|
FP=fileopen(FILENAME);
|
|
word temp;
|
|
printf("你想写入的单词:");
|
|
scanf("%s",temp.english);
|
|
printf("此单词的中文:");
|
|
scanf("%s",temp.chinese);
|
|
printf("例句:");
|
|
scanf("%s",temp.mean);
|
|
printf("属性:");
|
|
scanf("%s",temp.shuxing);
|
|
fwrite(&temp,sizeof(temp),1,FP);
|
|
printf("添加成功!!!!!");
|
|
fileclose(FP);
|
|
printf("继续输入Y/退出N");
|
|
char b=getch();
|
|
if(b==89)
|
|
goto stop;
|
|
}
|
|
|
|
|
|
int caidan()//菜单
|
|
{
|
|
int choose=1;
|
|
while(choose!=0)
|
|
{
|
|
printf("\n");
|
|
printf(" *********************************************************\n");
|
|
printf(" # #\n");
|
|
printf(" # 请选择系统功能选项 #\n");
|
|
printf(" # #\n");
|
|
printf(" *********************************************************\n");
|
|
printf(" # #\n");
|
|
printf(" # 0.退出 1.输入单词 #\n");
|
|
printf(" # #\n");
|
|
printf(" # 2.查找单词 3.清屏 #\n");
|
|
printf(" # 4.查看收藏夹 #\n");
|
|
printf(" *********************************************************\n");
|
|
printf("\n");
|
|
scanf("%d",&choose);
|
|
switch(choose)
|
|
{
|
|
case 0:return 0;break;
|
|
case 1:putinto();break;
|
|
case 2:change();break;
|
|
case 3:system("cls");break;
|
|
case 4:findlike();break;
|
|
}
|
|
}
|
|
}
|
|
|
|
int main()//主函数
|
|
{
|
|
caidan();
|
|
}
|