# include & ltstdio.h & gt
# include & ltconio.h & gt
主()
{
FILE * fp
char鍵[20],ch;
int i,l,num = 0;
if((fp=fopen("d:\\word.dat "," w+")= = NULL)
{ printf("無法打開文件");
getch();
退出(0);
}
Printf("輸入文章(按#結束)_ \ n ");
做{
ch = getchar();
fputc(ch,FP);
}while(ch!='#');
getchar();
printf(" \ n輸入要查詢的關鍵字_ ");
獲取(鍵);
倒帶(FP);
ch = fgetc(FP);
而(ch!=EOF)
{
if(ch==key[0])
{
l=strlen(鍵);
for(I = 1;我& ltl;i++)
{
ch = fgetc(FP);
如果(ch!= key[I])break;
}
num++;
}
ch = fgetc(FP);
}
Printf("***: %d (%s)\n ",num,key);
getch();
}