#include "stdio.h" #include "stdlib.h" #include "string.h" #include #include #define FILENAME "翻译文档31.txt" #define shoucanjia "收藏夹56.txt" struct word { char chinese[100]; char english[100]; char mean[100]; 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; FILE *fileopen(char FileName[])//打开翻译文档 { FILE *fp; if((fp=fopen(FileName,"rb"))==NULL) { color(4); printf("NO"); } fp=fopen(FileName,"ab+"); } void fileclose(FILE *fp)//关闭翻译文档 { if(fclose(fp)!=NULL) { color(4); 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