I am reading a file consisting of characters '*' and '$' and ' '.
I verify the characters are placed properly into the array but reading them back out of the array produces mess.
also, I can not get this code to stop reading garbage after the last character in the file.
Anyone help please.
Code:
char dungeonDB[8][37];
void readDungeonFile()
{
FILE *inputFile;
inputFile = fopen ("C:\\Users\\ishareef\\Desktop\\dungeon.dat", "r");
if ( inputFile == NULL )
printf ("Unable to load dungeon.dat and generate the dungeon. Please check the file path.\n");\
else
{
while (theChar != EOF)
{
for (i = 0; i < 8; i++)
{
for (j = 0; j < 37; j++ )
{
theChar = getc (inputFile);
dungeonDB[i][j] = theChar;
printf("%c", dungeonDB[i][j]);
}
}
}
}
fclose (inputFile);
printf("\n");
for (i = 0; i < 8; i++)
{
for (j = 0; j < 37; j++ )
{
theChar = dungeonDB[i][j];
printf("%c", theChar);
}
}
}