2
I have a problem, I want to receive a file and copy the information from that file to an array allocated by me:
Content that exists inside the file:
2..E.5..A......D
....1E....7B80..
F.8.A.......C.4.
AC...3.F...E.61.
.3...C.45..2..BF
.D9.5..31.A..E0.
E5A...9..0..7C..
...C6..B.E..5.2.
.9......ED0F...C
.E...8.DC..A..F7
....EB7...9.....
5....FAC......D.
.6..C7B9....F.5.
8.........D.94.2
..2..D1...C63..B
.7..8..6.BF..D..
And I want to copy it to a 16 by 16 matrix that I created, and the function that does that is here:
char** lerMatriz(char ** tabuleiro, char * arquivo, int l, int c)
{
char** tabuleiroP;
int i, j;
char carac;
FILE* p;
p = fopen(arquivo, "r");
for(i = 0 ; i < 16; i++)
{
for(j = 0; j < 16; j++)
{
tabuleiroP = fgets(tabuleiro, 256, p);
}
}
for(i = 0; i < 16; i ++)
{
for(j = 0; j < 16; j++)
{
printf("%c", tabuleiro[i][j]);
}
printf("\n");
}
fclose(p);
}
Being my char** tabuleiro
my matrix 16 x 16, char* arquivo
my string containing the file name and int l
and int c
the number of rows and columns of the matrix (16 x 16).
What would be the problem in my code?