I'm having a huge issue getting simple character matrix from a file.
I have this file: maze.txt
bxbbxbbbbxbb
bbbbbbxxxbxb
bxbbbxbbbxbb
bbxbbbbxbbxb
bxxxxbxbbxbb
bxbbbbbbxbbb
bxbbxxbxbbxb
bxxbxbbxbxxb
bxbxbbxbbxbb
xbbbbbbbbxbb
bbbxxxbbbbxb
bxbxxxxbbxbb
and i just want to read it into a 2d array of chars. I have a working output function, and when i output the result of this function, it is simply garbage. Anyone see what's wrong??
Thanks,
David
struct COORD InputMaze(int *maze[][101])
{
int row;
int col;
char InputChar[1];
struct COORD Size;
FILE *instream;
instream=fopen("maze.txt","r");
/*
fscanf(instream,"%i",&Size.row);
fscanf(instream,"%i",&Size.col);
*/
for(row=1;row<=12;row++)
{
for(col=1;col<=12;col++)
{
fscanf(instream, "%c", &InputChar);
maze[row][col]=InputChar;
}
InputChar[0]=fgetc(instream);//get rif of the \0 terminator
}
fclose(instream);
OutputMaze(maze,12,12);
return Size;
}