title: Find a string inside a binary file and print every time it appears
body: <p>Hi I am trying to create a function which will take input from the user in the form of a string search a binary file which contains football results e.g (Chelsea,liverpool,1,2) and print each time the string appears for example if the user enters liverpool then all of liverpool's results will be printed to the screen.The code I have does not print anything. What am I doing wrong?
  Here is what I have.</p>
  
  <pre><code>struct matches 
  {
      //structure members
      char teamA [100]; 
      char teamB [100];
      int goalsA;
      int goalsB;
  };    
  void displayMatches()
      {   
          struct matches match; //declare variable of type struct
  
          char input[20]; //variable to take input from user 
  
          FILE * file1; //pointer to a file
  
          file1 = fopen("matches.bin","rb");//open binary file in read mode 
  
          if(file1==NULL) //error check for file
          {
              printf("open file error.\n");
              exit(6);
          }
  
          printf("Enter the team\'s results you want to view\n");
          scanf("%s",input);
  
          /*loop to read binary file check if input team 
           is in file if yes print the results for that team */
          while(fread(&amp;match,sizeof(match),1,file1)) 
          {
  
  
  
              if(strstr(match.teamA,input))
              {
  
                  printf(" %s %s %i %i ",match.teamA,match.teamB,match.goalsA,match.goalsB);
  
              } 
              else if(strstr(match.teamB,input))
              {
  
                  printf(" %s %s %i %i ",match.teamA,match.teamB,match.goalsA,match.goalsB);
  
              }
  
          }
  
          fclose(file1);
      }
  </code></pre>