Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int strcmp1(char *a,char *b,int flag)
- {
- if(strcmp(strstr(a,b),b)==0)
- return 1;
- else
- return flag;
- }
- main()
- {
- int flag=0,a=0;
- int z=0;
- int i=0,j;
- char w[50];
- char t[20],refer[50];
- char k;
- FILE *f1;
- FILE *f2;
- printf("Enter word:");
- scanf("%s",w);
- f1=fopen("refer.txt","r+");
- f2=fopen("replica.txt","w");
- while(!feof(f1))
- {
- k=getc(f1);
- t[a]=k;
- refer[i]=k;
- if(k==' ')
- {
- flag=strcmp1(t,w,flag);
- for(j=0;j<a;j++)
- t[j]='\0';
- a=0;
- }
- else
- a++;
- if(k=='\n')
- { flag=strcmp1(t,w,flag);
- for(j=0;j<=a;j++)
- t[j]='\0';
- a=0;
- if(flag==0)
- {
- for(j=0;refer[j]!='\n';j++)
- {
- fputc(refer[j],f2);
- }
- fputc('\n',f2);
- }
- flag=0;
- for(j=0;refer[j]!='\n';j++)
- {
- refer[j]='\0';
- }
- i=0;continue;
- }
- i++;
- /*if(k=='\n')
- qw++;
- if((k==' ')||(k=='\n')||!(foef(f1++)))
- {
- t[i-1]='\0';
- (strcmp(strstr(t,w),w)==0);
- line[qw]=1;
- while((k=getc(f1))!='\n');*/
- }
- fclose(f1);fclose(f2);
- remove("refer.txt");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement