读取文本文件并以ascii格式显示内容

读取文本文件并以ascii格式显示内容,c,arrays,ascii,maze,C,Arrays,Ascii,Maze,我试图读取一个迷宫文件,并在代码运行时转换为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 -

我试图读取一个迷宫文件,并在代码运行时转换为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");
    }
}
#包括
#包括
#定义高度8
#定义宽度12
#定义墙219
#定义空间“”
//象征
//这里有一个空间——迷宫中的一个净空
//1-一堵墙
//2-入口门(起点)
//3-出口门
//4-内部目的地(终点)
//5-路标
虚空显示迷宫(inti,intj);
字符迷宫[高度][宽度];
int i,j;
int
main()
{
文件*myFile;
myFile=fopen(“example1.txt”、“r”);
fclose(myFile);
显示迷宫(i,j);
返回(0);
}
无效的
显示迷宫(int i,int j)
{
printf(“迷宫:\n”);
对于(i=0;i
2件事:(1)将其压缩为一个或尽可能接近的值。(2) 解释出哪里出了问题。不要只是说“它不起作用”;解释你为什么认为是这样。注意我选择说“你为什么思考”——也解释一下你的思考过程。你好,我是c的新手。我希望代码能够读取文件内容并以ascii格式打印您的问题,而不仅仅是发表评论。再次,包括一个,以及什么是错误的-要详细。我们无法读懂你的心思,很难读懂不正确的代码并了解应该发生什么?好的,谢谢,我会尽可能地复制