From c19677cdcdc6235309e3308969ea23968bdd9a76 Mon Sep 17 00:00:00 2001 From: 13574675339 <13574675339@139.com> Date: Thu, 10 Jan 2019 09:22:19 +0800 Subject: [PATCH] second commit --- 查找函数.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 查找函数.cpp diff --git a/查找函数.cpp b/查找函数.cpp new file mode 100644 index 0000000..4e65ca6 --- /dev/null +++ b/查找函数.cpp @@ -0,0 +1,45 @@ +void enter() +{ + int i,m=0; + char n; + char to[20],ch[2]; + printf("ÇëÊäÈëµ¥´Ê: "); + scanf("%s",to); + FILE *fp; + if((fp=fopen("data.txt","ab+"))==NULL) + { + printf("Îļþ²»´æÔÚ!\n"); + exit(1); + } + while(!feof(fp)) + { + if(fread(&inf[m],LEN,1,fp)==1) + { + if(strcmp(to,inf[m].word)==0) + { + printf("ÊÍÒå: "); + printf("%s\n",inf[m].mean); + printf("ÊÇ·ñ¼ÌÐø?"); + printf("°´Y»òy±íʾ¼ÌÐø,°´ÆäËü¼ü·µ»Ø\n"); + scanf("%c",&n); + fclose(fp); + return; + } + } + m++; + } + printf("Î޴˵¥´Ê!\n"); + printf("ÊÇ·ñ¼ÌÐø?"); + printf("°´Y»òy±íʾ¼ÌÐø,°´ÆäËü¼ü·µ»Ø\n"); + scanf("%c",&n); + fclose(fp); + return; + if(m==0) + printf("ÎļþÖÐÎ޼Ǽ!\n"); + if((fp=fopen("data.txt","ab+"))==NULL) + { + printf("Îļþ²»´æÔÚ!\n"); + return; + } + fclose(fp); +}