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); +}