This is one void function from a larger program, with the function of printing a kind of chart. It would first print the header, and then it uses a for loop to print 13 lines that calls information from 4 arrays. Names, a 2D Char Array, Scores, a 2D Int Array, Average, a 1D Float array, and Letter, a 1D Char array.
The function itself looks like this:
void display(char names[][8], int scores[][4], float *average, char *letter)
{
int q = 0;
printf("\n\n Name \t E1 \t E2 \t E3 \t E4 \t Avg \t Grade");
for(q=0; q<13; q++)
{
printf("\n %s \t %d \t %d \t %d \t %d \t %.2f \t %c", names[q][0], scores[q][0],
scores[q][1], scores[q][2], scores[q][3], average[q], letter[q]);
}
return;
}
Once I run it, it runs well until the function call for this, and once I get there, I get a segmentation fault. As a reference, this is the function call:
display(&names, &scores, &average, &letter);
Changing the %s in the printf to a %c stops the segmentation fault but I need it to be printing the string held in the array not just a single character.
So how would I print the string (and the statement as a whole) without a segmentation fault?