rendered paste body#include <stdio.h>
#include <string.h>
main(int argc, char *argv[]){
FILE *f;
char path[50], string[50], S;
int i=0, j=0, k=0, M, l[100], counter=0;
if (argc == 1){
printf("\nDwse to onoma tou arxeiou pros anagnwsh : ");
scanf("%s", path);
}
else
strcpy(path, argv[1]);
f = fopen(path, "r");
if (!f){ /*elegxos arxeiou*/
printf("\n\nSfalma kata to anoigma tou arxeiou %s\n\n", path);
return 1;
}
printf("\nDwse to string pros anazhthsh : ");
scanf("%s", string);
M = strlen(string);
/*########################################################################################*/
printf("\npath = %s, string = %s, string lenght = %d\n", path, string, M);
/*########################################################################################*/
while (!feof(f)){
S = fgetc(f);
counter++;
printf("M = %d\n", M);
/*########################################################################################*/
/*printf("%c", S);
fseek(f, -2*sizeof(char), SEEK_CUR);
S = fgetc(f);
printf("%c", S);
break;
/*########################################################################################*/
j=0;
/*printf("***** j = %d, M = %d, counter = %d\n", j, M, counter);*/
while ((j<=M) && (S==string[i])){
/*########################################################################################*/
/*printf("***** j = %d, M = %d, S = %c, string[%d] = %c\n", j, M, S, j, string[j]);
/*########################################################################################*/
i++;
j++;
S = fgetc(f);
}
if (j=M+1){
k++;
l[k]=counter-M;
}
i=0;
if (M!=5){
printf("%d", counter);
break;
}
}
printf("\n\nH leksh %s brethike %d fores sto arxeio %s, stis theseis : \n", string, k, path);
/* for(i=0;i<k;i++)
printf("%d) %d\n", i, l[i]);*/
}