my code is getting errors and i cant figiure out why , can you check my code and help me fix the errors . written in c code. It needs to print out a maze and as you hit enter you go through the maze.    #include <stdio.h>#include <stdlib.h> #define XSTART 2#define YSTART 0 #define DOWN 0#define RIGHT 1 #define UP 2#define LEFT 3 void mazeTraverse(char  maze [12][12],int xCor,int yCor,int dir);int checkForEdge(int x , int y);int correctMoves (char maze[][12],int r , int c );void displayMaze (char maze [][12]); int main (void){ char maze [12] [12] ={{'#','#','#','#','#','#','#','#','#','#','#','#'},  {'#','.','.','.','#','.','.','.','.','.','.','#'},  {'.','.','#','.','#','.','#','#','#','#','.','#'},  {'#','#','#','.','#','.','.','.','.','#','.','#'},  {'#','.','.','.','.','#','#','#','.','#','.','.'},  {'#','#','#','#','.','#','.','#','.','#','.','#'},  {'#','.','.','#','.','#','.','#','.','#','.','#'},  {'#','#','.','#','.','#','.','#','.','#','.','#'},  {'#','.','.','.','.','.','.','.','.','#','.','#'},  {'#','#','#','#','#','#','.','#','#','#','.','#'},  {'#','.','.','.','.','.','.','#','.','.','.','#'},  {'#','#','#','#','#','#','#','#','#','#','#','#'} };  mazeTraverse(maze,XSTART,YSTART,RIGHT);    return 0;} void mazeTraverse(char maze[12] [12] , int xCor ,int yCor , int dir) {    static int flag =0;     maze[xCor][yCor]='X';    displayMaze(maze);     if (checkForEdge(xCor,yCor) && xCor != XSTART && yCor !=  YSTART)    {        printf("\n successfully exited the maze\n\n");        return;    }    else if (xCor == XSTART  &&  yCor == YSTART  &&  flag ==  1)    {        printf("\nArrived back to starting position.\n\n");        return ;    }     else    {        int counter;        int nextMove;        flag = 1;         for ( nextMove = dir , counter=0; counter < 4 ; ++counter,++nextMove, nextMove %= 4)        {            switch (nextMove)            {             case DOWN:                 if(correctMove (maze, xCor + 1, yCor ))                {                    mazeTraverse(maze,xCor + 1,yCor,LEFT);                    return;                }             break;             case RIGHT :                if ( correctMove(maze,xCor,yCor + 1))                {                    mazeTraverse(maze, xCor,yCor + 1 , DOWN);                    return ;                }                 break;             case UP:                 if (correctMove(maze, xCor - 1,yCor))                {                    mazeTraverse(maze, xCor - 1 , yCor,RIGHT);                    return;                }                 break;             case LEFT :                 if(correctMove(maze, xCor,yCor - 1))                {                    mazeTraverse( maze , xCor,yCor -1, UP);                    return;                }                 break;             }        }    } int correctMove(char maze [][12],int r , int c ){    return(r>=0  && r <= 11 &&  c>= 0  && c <= 11  &&  maze[r][c]  !=  '#' );} int checkForEdge(int x , int y ){    if ((x == 0 || x == 11)&& (y >= 0 &&  y <= 11))    {        return 1;    }    else if ((y == 0 || y == 11) && (x >= 0 && x <= 11) )    {        return 1;    }    else    {        return 0;    }} void displayMaze(char maze [] [12]){    int x ;     int y ;     for (x = 0; x < 12 ; x++ )    {        for (y = 0; y < 12 ; y++)        {            printf ( " %c ", maze[x] [y]);        }        printf("\n");    }    printf("\n hit the return key to get next move");     getchar();}}

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

my code is getting errors and i cant figiure out why , can you check my code and help me fix the errors . written in c code. It needs to print out a maze and as you hit enter you go through the maze. 

 

#include <stdio.h>
#include <stdlib.h>
#define XSTART 2
#define YSTART 0
#define DOWN 0
#define RIGHT 1
#define UP 2
#define LEFT 3
void mazeTraverse(char  maze [12][12],int xCor,int yCor,
int dir);
int checkForEdge(int x , int y);
int correctMoves (char maze[][12],int r , int c );
void displayMaze (char maze [][12]);

int main (void)
{
 char maze [12] [12] =
{{'#','#','#','#','#','#','#','#','#','#','#','#'},
 {'#','.','.','.','#','.','.','.','.','.','.','#'},
 {'.','.','#','.','#','.','#','#','#','#','.','#'},
 {'#','#','#','.','#','.','.','.','.','#','.','#'},
 {'#','.','.','.','.','#','#','#','.','#','.','.'},
 {'#','#','#','#','.','#','.','#','.','#','.','#'},
 {'#','.','.','#','.','#','.','#','.','#','.','#'},
 {'#','#','.','#','.','#','.','#','.','#','.','#'},
 {'#','.','.','.','.','.','.','.','.','#','.','#'},
 {'#','#','#','#','#','#','.','#','#','#','.','#'},
 {'#','.','.','.','.','.','.','#','.','.','.','#'},
 {'#','#','#','#','#','#','#','#','#','#','#','#'}
 };
 mazeTraverse(maze,XSTART,YSTART,RIGHT);
    return 0;
}
void mazeTraverse(char maze[12] [12] , int xCor ,int yCor , int dir)
{
    static int flag =0;
    maze[xCor][yCor]='X';
    displayMaze(maze);
    if (checkForEdge(xCor,yCor) && xCor != XSTART && yCor !=  YSTART)
    {
        printf("\n successfully exited the maze\n\n");
        return;
    }
    else if (xCor == XSTART  &&  yCor == YSTART  &&  flag ==  1)
    {
        printf("\nArrived back to starting position.\n\n");
        return ;
    }
    else
    {
        int counter;
        int nextMove;
        flag = 1;
        for ( nextMove = dir , counter=0; counter < 4 ; ++counter,++nextMove, nextMove %= 4)
        {
            switch (nextMove)
            {
            case DOWN:
                if(correctMove (maze, xCor + 1, yCor ))
                {
                    mazeTraverse(maze,xCor + 1,yCor,LEFT);
                    return;
                }
            break;
            case RIGHT :
                if ( correctMove(maze,xCor,yCor + 1))
                {
                    mazeTraverse(maze, xCor,yCor + 1 , DOWN);
                    return ;
                }
                break;
            case UP:
                if (correctMove(maze, xCor - 1,yCor))
                {
                    mazeTraverse(maze, xCor - 1 , yCor,RIGHT);
                    return;
                }
                break;
            case LEFT :
                if(correctMove(maze, xCor,yCor - 1))
                {
                    mazeTraverse( maze , xCor,yCor -1, UP);
                    return;
                }
                break;
            }
        }
    }

int correctMove(char maze [][12],int r , int c )
{
    return(r>=0  && r <= 11 &&  c>= 0  && c <= 11  &&  maze[r][c]  !=  '#' );
}
int checkForEdge(int x , int y )
{
    if ((x == 0 || x == 11)&& (y >= 0 &&  y <= 11))
    {
        return 1;
    }
    else if ((y == 0 || y == 11) && (x >= 0 && x <= 11) )
    {
        return 1;
    }
    else
    {
        return 0;
    }
}
void displayMaze(char maze [] [12])
{
    int x ;
    int y ;
    for (x = 0; x < 12 ; x++ )
    {
        for (y = 0; y < 12 ; y++)
        {
            printf ( " %c ", maze[x] [y]);
        }
        printf("\n");
    }
    printf("\n hit the return key to get next move");
    getchar();
}
}
 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Topological Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education