我正在尝试读取迷宫文件并转换为ascii并在代码运行时显示。我似乎无法得到它。我如何阅读和显示文件。提前谢谢
#include <stdio.h>
#include <stdlib.h>
#define height 8
#define width 12
#define WALL 219
#define SPACE ' '
//symbols
// where a space - a clear space in the maze
// 1 - a wall
// 2 - the entrance door(starting point)
// 3 - exit door
// 4 - internal destination point(end point)
// 5 - a way point
void displaymaze(int i, int j);
char maze[height][width];
int i, j;
int
main()
{
FILE *myFile;
myFile = fopen("example1.txt", "r");
fclose(myFile);
displaymaze(i, j);
return (0);
}
void
displaymaze(int i, int j)
{
printf("MAZE:\n");
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
if (maze[i][j] == '1') {
maze[i][j] = WALL;
}
else if (maze[i][j] == ' ') {
maze[i][j] = SPACE;
}
else if (maze[i][j] == '2') {
maze[i][j] = ('S');
}
else if (maze[i][j] == '3')
maze[i][j] = ('E');
printf("%c", maze[i][j]);
}
printf("\n");
}
}