I am trying to make a code to read in from a file which looks like this
2 2 (num contestants and judges)
50 100 (scores contestant 1)
90 98 (scores contestant 2)
I want to read the scores into a [i][j] array and print it out and im having trouble.
You can see where I tried to start my array. Any ideas/hints?
Code:
#include <stdio.h>
#include <stdlib.h>
int main () {
int i,j,max_c, max_j;
int num_shows;
FILE * fin;
fin = fopen("ucfidol.txt","r");
fscanf(fin,"%d", &num_shows);
printf("%d\n",num_shows);
fscanf(fin,"%d",&max_c);
printf("Number of contestants = %d\n", max_c);
fscanf(fin,"%d",&max_j);
printf("Number of judges = %d\n", max_j);
int scores[i][j];
for(i=1;i<=max_c;i++)
for(j=1;i<=max_j;j++)
fscanf(fin,"%d",&scores[i][j]);
for(i=1;i<=max_c;i++)
for(j=1;i<=max_j;j++)
printf("%d", board[i][j]);
printf("\n");
fclose(fin);
system("PAUSE");
return 0;
}