Can i change the array's rows length after i define it as constant or any other way?
Can you under my code or explanation?
#include<stdio.h>
#define CLASS_SIZE 20 //First define the array rows's length
void main()
{
double gpa, average, highest, lowest;
int student, rows, i, j;
char grade[CLASS_SIZE][5]; //Wish to change the CLASS_SIZE
printf("Enter the number of student : ");
scanf("%d", &CLASS_SIZE); //Can i change the arrays length after declared ?
for(j=0;j<CLASS_SIZE;j++) //What should i modify?
{
printf("\nStudent No.%d :\n", j+1);
for(i=0;i<5;i++)
{
printf("Enter subject %d's grade : ", i+1);
fflush(stdin);
scanf("%c", &grade[j][i]);
}
}
printf("+===========+=============================+\n");
printf("| | SUBJECT |\n");
printf("| STUDENT +=============================+\n");
printf("| | 1 | 2 | 3 | 4 | 5 |\n");
printf("+===========+=============================|\n");
for(j=0;j<rows;j++)
{
printf("| %d |", j+1);
for(i=0;i<5;i++)
{
printf(" %c |", grade[rows][i]);
}
printf("\n");
}
printf("+===========+=============================+\n");
}