Question
C Programming- Maze Game: The layout of the maze is given below. + suggests a block or wall that cannot pass. . is a passable
C Programming- Maze Game: The layout of the maze is given below. + suggests a block or wall that cannot pass. . is a passable tile. * is your start/current location and E is the exit/goal.
#include #include int main(){ FILE *fptr; char ch; int i = 0, j = 0; fptr = fopen("---input your own directory of file here---", "r"); if (fptr == NULL) { printf("Cannot open file "); exit(0); } while ((ch = fgetc(fptr)) != EOF) { if (ch == ' ') continue; if (ch == ' '){ j=0; i++; continue; } if (ch == '*'){ x = i; y = j; } maze[i][j++] = ch; } fclose(fptr); return 0; }
a. Read the maze layout from the text file and put it into a 2D array.
b. Write a function to print the maze.
c. Write a function that accepts a direction {u,d,l,r} and moves the asterisk 1 tile toward that direction. The function should alert the user with invalid move if it runs into a wall and the asterisk should stay still. The function should also tell the user when the exit is reached.
d. Write a loop to prompt the user to input a direction at each step until the exit/goal is reached.
C C Programming- Maze C C Programing. Maze Trav Hw3pdf ? ? ?? Secure ! https://blackboard.gwu.edu/bbcswebdav/pid?8644884-dt-content-rid-32446401-2/courses/35188-201801/Hw3.pdf points) write te a Tunctron + a R ^ qx 4/24/2018 10:43 AM O Type here to search D e C C Programming- Maze C C Programing. Maze Trav Hw3pdf ? ? ?? Secure ! https://blackboard.gwu.edu/bbcswebdav/pid?8644884-dt-content-rid-32446401-2/courses/35188-201801/Hw3.pdf points) write te a Tunctron + a R ^ qx 4/24/2018 10:43 AM O Type here to search D eStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started