Your first line of code with errors is:
Code:
int subjects_taken,row_count = 0 ,Array[200][5], i , j ,student_no = 1,row_t *Array = NULL;;
row_t is an int, but has no comma after it.
*Array is the same name as the Array[200][5] has, so that's no good.
You have two ;; semi-colons on the end of the line, instead of one.
Next is:
Code:
typedef double row_t[MAX_COLLUMN];
row_t is already declared as an int. For now, avoid typedef's. I deleted this line, entirely.
Next is:
Code:
if (row_count > 0)
{
Array = malloc(row_count * sizeof(row_t));
}
Array is declared with a fixed size. Delete this line of code. You can't declare array sizes, and then try and malloc them as well.
Next is:
For a comparison to be made, you need two ==. One = is for assignment only. You have several lines of this, in your code.
Next is in this same loop:
Code:
for(i=0;i<5;i++)
{
printf("Enter Student #%d's Grade for subject #%d",student_no,i);
scanf("%c", &grade);
if (grade = 'A')
Array[MAX_ROWS][i] = 4.0;
else if (grade = 'B')
Array[MAX_ROWS][i] = 3.0;
else if (grade = 'C')
Array[MAX_ROWS][i] = 2.0;
else if (grade = 'D')
Array[MAX_ROWS][i] = 1.0;
else if (grade = 'E')
Array[MAX_ROWS][i] = 0.0;
}
You need to #define MAX_ROWS. Also, you can't use Array[MAX_ROWS][i], in this way, for two reasons:
1) MAX_ROWS is not a valid index number. Highest valid index for Array is Array[MAX_ROWS - 1], because indices in C arrays, begin at 0, not 1.
2) You need a variable here, not a constant value, otherwise you'll assign every GPA to the very last index, only.
I'll show how to do that, in a follow up post. For now, I'm adding
#define MAXROWS 20
Up above int main().
And yes, it's always int main(), never main(), and never void main(). Teachers and some books have used that for years (because it's easier, and a bit complicated), but int main() is what the operating system will use to determine (report) whether your program ran normally (not accurately!) just ran normally, or not. So:
Code:
int main(void) {
//all your code here
return 0; //return other than zero, by convention, would indicate an error
}