I'm using the following to read a 3 line by 3 column file and storing it into the array. However, when I try to print out the array contents, only the first line is correct. The rest is either gibberish smiley faces or sometimes numbers.
Code:char read, array[3][3]; int i=0, j=0; FILE *test = fopen("test.txt","r"); while (!feof(test)) { fscanf(test, "%c", &read); if (read=='\n') break; else array[i][j]=read; if (i<3 && j<3) j++; else if (i<3 && j==3) i++; }