title: Finding a string in txt file
body: <p>Building a C program and could use a helpful hand. Making a data structure, where I can fill in user information, like name, surename, gender etc etc and all goes in to a text file. Everything except one thing is working fine.</p>
  
  <p>part of the main</p>
  
  <pre><code>int main()
  {
  FILE *fp;
  struct info
  {
    char name[15];
    char surename[15];
    char gender[10];
    char education[15];
   } info;
  
  char education1[50];
  </code></pre>
  
  <p>then goes non important part of the code, until we get to the point where if user so desires he can choose to show only registers with for example bachelors degrees. This is how far I've gotten to make it happen but it does not work. Any ideas?</p>
  
  <pre><code>FILE *fp=fopen("info.txt", "a");
    while(fp!=NULL &amp;&amp; fgets(education1, sizeof(eductaion1),fp)!=NULL)
    {
                   if(strstr(education1,"bachelors"))
                  fprintf(fp, "\n%s %s %s %s",
                  sem.name,
                  sem.surename,
                  sem.gender,
                  sem.education,);
                  if(fp!=NULL) fclose(fp);   
  
    }
  </code></pre>