ERROR
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define size 4
void read_world(FILE *inp,x[][size])
int i, j, t;
if (inp==NULL) {
printf("File is missing\n");
return (0);
}
else {
for (i=0;i < 4;i++) {
for (j=0;j < 4;j++) {
(fscanf(inp, "%d", &t)); // error only reads first row of text
x[i][j]=t;
}
printf("%d\n", x[i][j]);
}
}
return(0);
}
int main(void) {
int i, j;
int g[4][4];
FILE*inp=fopen("world.txt", "r"); // reads file
read_world(inp, g);
return (0);
}
Code needed to read text from .txt file called world. Its a very simple code that do sent seem to read properly, the file consist of numbers and characters like "0"s and " * " which are arranged in a 4 by 4 matrix. the outcome is just to print the content of the file on the screen.