title: Segmentation fault in last iteration of for loop
body: <p>I am writing some code that calculates the final grade of a student given the grades and weights for each component. I am running into a segmentation fault when the following for loop is supposed to exit.</p>
  
  <pre><code>for (i = 0; i &lt; course.numOfSchemes; i++){
  printf("Marking scheme# %u \n", i);
      for (j = 0; j &lt; course.numOfComponents; j++){
          printf("  Enter %s weight: ",course.components[j]);
          scanf("%f", &amp;course.weights[i][j]);
      }
      printf("End: %u \n \n",i);
  }
  printf("rrr");
  </code></pre>
  
  <p>So, supposing course.numOfSchemes = 2 and course.numOfComponents = 3, this is what a trial run would look like. You'll notice that The loop goes from beginning to end twice, but the text "rrr" never gets printed. Therefore, I am assuming the fault happens during the check that happens when the loop is trying to quit.</p>
  
  <pre><code>Marking scheme# 0 
    Enter A weight: 20
    Enter B weight: 30
    Enter C weight: 50
  End: 0 
  
  Marking scheme# 1 
    Enter A weight: 40
    Enter B weight: 40
    Enter C weight: 20
  End: 1 
  
  Segmentation fault (core dumped)
  </code></pre>