- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #define test "test.txt"
- main()
- {
- FILE *flot;
- char v,*chaine,*res;
- int c,j,s;
- long i ;
- flot=fopen(test,"r+");
- i=ftell(flot);
- chaine=malloc(sizeof(char));
- res=malloc(sizeof(char));
-
- printf("saisiser une chaine de caractere\\\\n");
- gets(chaine);
- s=strlen(chaine);
- while((c=fgetc(flot))!=EOF)
- {
- fseek(flot,-1,SEEK_CUR);
- for(j=0;j<s;j++)
- {
- fscanf(flot,"%c",&v);
- if(chaine[j]!=v)
- {
- break;
- }else
- res[j]=v;
- }
- }
- for(j=0;j<s;j++)
- printf("%c",res[j]);
- fclose(flot);
- return(0);
- }
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define test "test.txt"
main()
{
FILE *flot;
char v,*chaine,*res;
int c,j,s;
long i ;
flot=fopen(test,"r+");
i=ftell(flot);
chaine=malloc(sizeof(char));
res=malloc(sizeof(char));
printf("saisiser une chaine de caractere\\\\n");
gets(chaine);
s=strlen(chaine);
while((c=fgetc(flot))!=EOF)
{
fseek(flot,-1,SEEK_CUR);
for(j=0;j<s;j++)
{
fscanf(flot,"%c",&v);
if(chaine[j]!=v)
{
break;
}else
res[j]=v;
}
}
for(j=0;j<s;j++)
printf("%c",res[j]);
fclose(flot);
return(0);
}