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....

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 \n"); exit(0); } while ((ch = fgetc(fptr)) != EOF) { if (ch == ' ') continue; if (ch == '\n'){ 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.
Nov 16, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here