Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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 e

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions