title: Segmentation fault: zsh: segmentation fault
body: <p>I get a segfault when I add (int filter) in the struct. Is it possible to fix?
  Error message: <strong>zsh: segmentation fault</strong></p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;stdbool.h&gt;
  #include &lt;string.h&gt;
  
  typedef struct Student {
      char name[30];
      char surname[30];
      int course;                 // year of study
      double average;             // average grade
      
      int load;                   // number of courses
      char courses[10][30];       // course names
      int grades[10];             // course grades
      
      
      char languages[100];        // spoken languages
      
      int negative;
  //    int filter;
  } Student;
  
  
  
  int main(int argc, char *argv[]) {
      FILE *db = NULL;
      // open database file for reading, provide a parameter or use default &quot;db.bin&quot;
      if (argc &gt; 1)
          db = fopen(argv[1], &quot;rb&quot;);
      else
          db = fopen(&quot;db.bin&quot;, &quot;rb&quot;);
          
      if (db){                            
          Student students[1000];         // all the data goes here
          int size = 0;                   // how many students in database
          
          // reading data from file
          fread(&amp;size, sizeof(int), 1, db);
          
          for (int i = 0; i &lt; size; i++){         
              fread(&amp;students[i], sizeof(Student), 1, db);            
          }   
          printf(&quot;%d records loaded succesfully\n&quot;, size);
          
          
          // MODIFY CODE BELOW
          
          int counterDemo = 0; // for counting students
  
          for (int i = 0; i &lt; size; ++i){ // process all the student records in database
              Student s = students[i]; // store data for each student in s
              s.negative = 0;
              // Checking if student has Philosophy and passed Philosophy exam
              for(int j = 0; j &lt; s.load; ++j)
              {
                  if(!strcmp(s.courses[j], &quot;Philosophy&quot;))
                  {
                      s.negative++;
                  }
                      
              }
              bool philosophy_exam = false;
              if(s.negative != 0)    // If student has Philosophy and passed Philosophy exam
              {
                  philosophy_exam = true;
              }
  
              if(philosophy_exam){ // *** first filter, conditions on the student
                  int anotherDemo = 0; // for counting courses/grades
                  printf(&quot;%s %s %d %.2f %d &quot;, s.name, s.surname, s.course, s.average, s.load); // print student data
  
                  for (int i = 0; i &lt; s.load; ++i){ // process each course taken by the student
                      if(1){ // *** second filter, conditions on the course/grade
                          ++anotherDemo; // counting courses
                          printf(&quot;%s %d &quot;, s.courses[i], s.grades[i]);
                      }
                  }
                  printf(&quot;%s\n&quot;, s.languages);
                  
                  if (anotherDemo == s.load) // *** third filter, various other conditions            
                      ++counterDemo; // counting studfents
              }
          }
          printf(&quot;Filter applied, %d students found\n&quot;, counterDemo); // how many passed the filters
          fclose(db); 
      } else {
          printf(&quot;File db.bin not found, check current folder\n&quot;);
      }
  
      return 0;
  }
  </code></pre>
  <p>I commented the problematic variable out.
  Also I run my code on terminal, like always. I am using (clang &quot;file&quot; -o main) could this be the problem? I have tried to run this code in different apps, but it doesn't help.</p>