|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **args)
{
char fnm[300],wrd[300],crwrd[300];
gets(fnm);
FILE *fl;
if((fl=fopen(fnm,"rt"))=='\0')
{
printf("\nErrore!File inesitente\n");
return -1;
}
printf("<<Stringa da cercare<<");
gets(wrd);
int there=0,i;
while(!feof(fl))
{
for(i=0;wrd[i]!='\0';i++)
{
if(fgetc(fl)==wrd[i]);
else
break;
}
if(wrd[i]=='\0')there++;
}
if(!there)
printf("\nLa parola non \212 presente");
else
printf("\nLa parola \212 presente %d volte",there );
return 0;
}
|
|