Im being asked to:
Write a program that takes as input two 3x3 arrays in file "Matrices.txt", whose contents are: 3 7 1 3 4 3 6 5 0 4 1 5 2 0 4 6 1 2
I am unsure how I am to go about using fscanf to pull the numbers from the txt file and put them into two seperate 2d arrays.
This is what I got going on:
`
#include <stdio.h>
#include <stdlib.h>
int main(){
int matrixA [3][3];
int matrixB [3][3];
FILE *fptr;
int i,j = 0;
fptr = fopen("Matrices.txt","r");
if(fptr == NULL){
printf("Errpr! File was not created!");
exit(1);
}
while(!feof(fptr)){
fscanf(fptr,"%d%d", &matrixA[i][j]);
i++;
j++;
}//while loop
fclose(fptr);
return 0;
}
`