C free memory from struct array <p>The assignment is to create a struct array with 10 elements as "students" and each have a score and an ID. There are some things I am not allowed to change in the code (like anything in main).</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; struct student* allocate(){ struct student* array = malloc(10 * sizeof(struct student)); return array; } void deallocate(struct student* stud){ int i = 0; for(;i&lt;10;i++) free(&amp;stud[i]); } </code></pre> <p>So this compiles fine and the rest of the code runs fine but then the core dumps when it gets to the free(). Also, this is the main that my professor gave me and told me not to change. There was no call to the deallocate function so now I am wondering if it automatically gets called when main is done or if he left it out by mistake. I added it in because I think that seems reasonable.</p> <pre><code>int main(){ struct student* stud = allocate(); generate(stud); output(stud); sort(stud); for(int i=0;i&lt;10;i++){ printf("%d %d\n", stud[i].id,stud[i].score); } printf("Avg: %f \n", avg(stud)); printf("Min: %d \n", min(stud)); deallocate(stud); return 0; } </code></pre>