title: Reading words of a .txt file not working C
body: <p>I wanted to search for specific words in a .txt file.</p>
  
  <p><strong>For example the file includes "Jon Miller, Andy Miller, Apu McDawn" 
  And I want to search for "Miller" in this file how often it occures.
  then it should show me the number (num) "2"</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(int argc, char const *argv[])
  {   
      int num =0;
      char word[100];
      char *string;
  
      FILE *in_file = fopen("test.txt", "r"); //reading the words
  
      if (in_file == NULL)
      {
          printf("Dataerror\n"); //if word not found
          exit(-1);
      }
  
      else {
          scanf("%s", word);
          printf("%s\n", word);
  
          while(!feof(in_file))//search for the word
  
          {
              fscanf(in_file,"%s", string);
              if(!strcmp(string , word))//if hit a word
              num++;
          }
  
          printf( "%d Hit \n" ,num );
      }
      return 0;
  }
  </code></pre>