Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
CercaParole - CercaParole.c

CercaParole.c

Caricato da:
Scarica il programma completo

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. int main(int argc, char **args)
  5. {
  6.     char fnm[300],wrd[300],crwrd[300];
  7.     printf("<<Nome file<<");
  8.     gets(fnm);
  9.     FILE *fl;
  10.     if((fl=fopen(fnm,"rt"))=='\0')
  11.     {
  12.         printf("\nErrore!File inesitente\n");
  13.         return -1;
  14.    
  15.     }
  16.     printf("<<Stringa da cercare<<");
  17.     gets(wrd);
  18.     int there=0,i;
  19.     while(!feof(fl))
  20.     {
  21.         for(i=0;wrd[i]!='\0';i++)
  22.         {
  23.             if(fgetc(fl)==wrd[i]);
  24.             else
  25.             break;
  26.         }
  27.         if(wrd[i]=='\0')there++;
  28.     }
  29.     if(!there)
  30.     printf("\nLa parola non \212 presente");
  31.     else
  32.     printf("\nLa parola \212 presente %d volte",there);
  33.    
  34.     return 0;
  35. }