I don't understand what this error is telling me. When I run the program it should continuously loop until the user enters N (for no more/exit). I don't understand what is going on. After the first set of inputs, before the user is prompted "Would you like to process a new student" the program throws out that exception.
I've run it using Geany (which doesn't give me any error definition it just crashes), and Visual Studio 2010.
Can someone help?
void draw_bar_chart(int student_id[], int percentage[], int size)
{
FILE *report;
int i, j=0, min = 1000000, max = 0, min_pos, max_pos, l;
char s[20];
report = fopen("report2.txt", "a");
fprintf(report, "\n******* BAR CHART (YEARLY TOTAL EXPENSES: YEARLY TOTAL INCOME) *******\n\n");
for (i = 0; i < size; i++)
{
fprintf(report, "%d%c", student_id[i], ' ');
if (percentage[i] > 0){
l = percentage[i]/10; //the lenght of the bar
if ((percentage[i]%10) > 0)
l++;
for (j = 0; j < l; j++)
s[j] = 'x';
s[l+1] = '\0';
} else {
s[0] = '!';
s[1] = '\0';
}
fprintf(report, "%-20s%6c%d%c\n", s, ' ', percentage[j], '%');
if (percentage[j] >= 0)
{
if (percentage[j] < min)
{
min = percentage[j];
min_pos = j;
}
if (percentage[j] > max)
{
max = percentage[j];
max_pos = j;
}
}
}
fprintf(report, "***lowest percentage: %d%c (student ID: %d)\n", min, '%', student_id[min_pos]);
fprintf(report, "***highest percentage: %d%c (student ID: %d)\n", max, '%', student_id[max_pos]);
fclose(report);
}