@{@XXX文本记录@}@ 文本记录格式 xxx 搜索词条
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
FILE *f=fopen("help.txt","r");
if(f==NULL){
perror("file");
return -1;
}
char nr[2000];
fseek(f,0,SEEK_END);
long len=ftell(f);
rewind(f);
char txt2[len];
for(int t=0;t<len;t++){
txt2[t]=fgetc(f);
}
// fclose(f);
int d=0;
int wz=0;
char txt1[10];
char bz1[10];
int t=0;
int k=0;
char txt[len];
char bz[14];
a: scanf("%s",bz1);
strcpy(bz,"@{@");
memcpy(txt,txt2,len);
strcat(bz,bz1);
printf("%s\n",bz);
d=0;
wz=0;
memset(nr,0,2000);
for(int t=0;t<(len-4);t++){
if(t==(len-3)) break;
if(((txt[t]=='@')&&(txt[t+1]=='{')&&(txt[t+2]=='@'))||(wz==1)){
wz=1;
nr[d]=txt[t];
d++;
}
if((txt[t]='@')&&(txt[t+1]=='}')&&(txt[t+2]=='@')) {
d=0;
wz=0;
memset(txt1,0,10);
memcpy(txt1,nr,strlen(bz));
if(memcmp(bz,txt1,strlen(bz))==0){
system("clear");
printf("%s\n",nr);
memset(nr,0,2000);
memset(bz,0,10);
goto a;
}
memset(nr,0,2000);
}
}
puts("没有匹配函数");
goto a;
return 0;
}
