first commit

master
Your Name 6 years ago
parent 271a0a7c82
commit 041b479c4b

@ -2,6 +2,7 @@
#include "stdlib.h"
#include "string.h"
#include<conio.h>
#include <windows.h>
#define FILENAME "翻译文档31.txt"
#define shoucanjia "收藏夹56.txt"
struct word
@ -12,6 +13,19 @@ struct word
char shuxing[100];
};
void color(short x) //自定义函根据参数改变颜色
{
if(x>=0 && x<=15)//参数在0-15的范围颜色
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), x); //只有一个参数,改变字体颜色
else//默认的颜色白色
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
}
FILE *FP;
@ -20,7 +34,7 @@ FILE *fileopen(char FileName[])//
FILE *fp;
if((fp=fopen(FileName,"rb"))==NULL)
{
printf("NO");
color(4); printf("NO");
}
fp=fopen(FileName,"ab+");
}
@ -29,7 +43,7 @@ void fileclose(FILE *fp)//
{
if(fclose(fp)!=NULL)
{
printf("close defit");
color(4); printf("close defit");
}
}
@ -141,11 +155,6 @@ void change()//
printf("退格:退后一个单词");
char c=getch();
stop: system("cls");
// if(c==49)
// {
// shoucan(temp);//收藏单词;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// break;
// }
if(c==32)
break;
printf(" 输入单词:");
@ -165,11 +174,11 @@ void change()//
i=i+1;
}
FILE *fp;
if((fp=fopen(FILENAME,"rb+"))==NULL)
{
printf("OPEN DEFIT");
}
if((fp=fopen(FILENAME,"rb+"))==NULL)
{
printf("OPEN DEFIT");
}
while(fread(&temp,sizeof(word),1,fp))
{
if(strcmp(temp.english,tempenglish)==0)
@ -185,19 +194,16 @@ void change()//
}
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);
fflush(stdin);
gets(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);
@ -210,32 +216,31 @@ void change()//
}
else
{
char *res = strstr(temp.english,tempenglish);
if(res != NULL)
else
{
printf("\n你要查找的可能是:\n中文是:%s 英文是:%s 例句是:%s 属性是:%s\n",temp.chinese,temp.english,temp.mean,temp.shuxing);
m=1;
}
else
{
n=2;
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");
printf("\n没有这个单词");
}
}
}
}
void putinto()//插入词库
{
color(2);
stop: printf("\n");
FP=fileopen(FILENAME);
word temp;
@ -244,7 +249,8 @@ stop: printf("\n");
printf("此单词的中文:");
scanf("%s",temp.chinese);
printf("例句:");
scanf("%s",temp.mean);
fflush(stdin);
gets(temp.mean);
printf("属性:");
scanf("%s",temp.shuxing);
fwrite(&temp,sizeof(temp),1,FP);
@ -252,7 +258,7 @@ stop: printf("\n");
fileclose(FP);
printf("继续输入Y/退出N");
char b=getch();
if(b==89)
if(b==89||b==121)
goto stop;
}
@ -260,8 +266,10 @@ stop: printf("\n");
int caidan()//菜单
{
int choose=1;
while(choose!=0)
{
color(1);
printf("\n");
printf(" *********************************************************\n");
printf(" # #\n");
@ -272,10 +280,10 @@ int caidan()//
printf(" # 0.退出 1.输入单词 #\n");
printf(" # #\n");
printf(" # 2.查找单词 3.清屏 #\n");
printf(" # 4.查看收藏夹 #\n");
printf(" # 4.查看收藏夹 #\n");
printf(" *********************************************************\n");
printf("\n");
scanf("%d",&choose);
scanf("%d",&choose);
switch(choose)
{
case 0:return 0;break;

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save