ahhh true, thank you, i didn't notice that, i changed that in my code and also added a while loop, but my output is still going on forever, instead of stopping after reading the matrix, any idea why? here's my revised code. Thank you
Code:
#include <stdio.h>
#include <stdlib.h>
FILE *fin, *fout;
main() {
int A [3] [4] ;
int r = 0;
int c = 0;
int r_max = 4;
int c_max = 5;
int i;
int j;
int k;
fin = fopen("matrix.txt", "r");
fout = fopen("output.txt", "w");
while(fscanf(fin, "%d", &k) != EOF ) {
for(r = 0; r < r_max; r++) {
for(c = 0; c < c_max; c++) {
fscanf(fin, "%d", &A[i][j]);
fprintf(fout, "%d ", A[i][j]);
}
fprintf(fout, "\n");
}
printf("%d",A[2][2]);
getchar();
}
}