I am trying to read a text file into an array and I'm having some trouble doing so. here is the code that I have so far. Any help would be much appreciated.
Code:
#include <stdio.h>
#include <ctype.h>
#define MAX_ROW 15
#define MAX_COL 6
int main()
{
FILE* numbers;
int x;
int ary[MAX_ROW][MAX_COL];
numbers = fopen("extradata.txt", "r+");
while (!feof(numbers))
{
fscanf(numbers, "%d", &x);
ary[MAX_ROW][MAX_COL] = x;
}
fclose(numbers);
for(int row; row<MAX_ROW; row++)
{
printf("\n");
for(int col; col<MAX_COL; col++)
{
printf("%3d", ary[row][col]);
}
}
return 0;
}
Comment