maze game

hello this is my assinment to make a maze game i have written this vode but when i enter character to move $ sign it does not print my maze again please can any one help me out thank u heres the code


i am using codeblocks as a compiler

#include <iostream>
#include<conio.h>
using namespace std;
int xstart=2;
int ystart = 0;
const int xmax = 8;
const int ymax = 8;
char maze[xmax][ymax] =
{
{'#','#','#','#','#','#','#','#'},
{'#','.','.','.','.','.','.','#'},
{'.','.','#','#','#','.','#','#'},
{'#','.','.','.','#','.','.','#'},
{'#','.','#','#','#','#','.','#'},
{'#','.','.','#','.','.','#','#'},
{'#','#','.','#','#','.','.','.'},
{'#','#','#','#','#','#','#','#'}
};

void printMaze();

int main()
{
cout<<"\t solve this maze!!!!!! "<<endl;
printMaze();
maze[xstart][ystart]='$';
printMaze();
char pos;
int n=20;
while( n>0)
{
cout<<"Enter \n w to move north \n a to move west \n d to move east \n s to move south \n q to move north-west \n e to move north-east \n z to move south-west \n s to move south east \n";
cin>>pos;
for(int row = 0; row < xmax; row++)

{
for(int col=0; col < ymax; col++)
{


if(pos=='w')
{
maze[xstart][ystart]=maze[row -1][col];
void printMaze();
// cout << maze[row][col];

}
else if(pos=='a')
{
maze[xstart][ystart]=maze[row][col-1];
void printMaze();

}
else if(pos=='d')
{
maze[xstart][ystart]=maze[row][col+1];
void printMaze();
// cout << maze[row][col];

}
else if(pos=='s')
{
maze[xstart][ystart]=maze[row+1][col];
void printMaze();
// cout << maze[row][col];

}
else if(pos=='q')
{
maze[xstart][ystart]=maze[row -1][col -1];
void printMaze();
// cout << maze[row][col];

}
else if(pos=='e')
{
maze[xstart][ystart]=maze[row -1][col+1];
void printMaze();
// cout << maze[row][col];

}
else if(pos=='z')
{
maze[xstart][ystart]=maze[row +1][col -1];
void printMaze();
// cout << maze[row][col];


}
else if(pos=='c')
{
maze[xstart][ystart]=maze[row +1][col+1];
void printMaze();
// cout << maze[row]<<[col];


}
else
{
cout<<"invalid move!!";
break;
}


}

}
void printMaze();
n++;
}
if(maze[xstart][ystart]==maze[6][7])
{
cout<<"done!!";

}
}


void printMaze()
{
cout<<"\n";
for(int row = 0; row < xmax; row++)
{
for(int col=0; col < ymax; col++)
cout << maze[row][col];
cout << "\n";
}
}


The reason your maze is not printing is the presence of void in front of printMaze().
e.g.
1
2
3
4
else if(pos=='e')
{ maze[xstart][ystart]=maze[row -1][col+1];
   void printMaze();
}

The causes printMaze to be interpreted as a forward function declaration, not a function call.

It should read:
1
2
3
4
else if(pos=='e')
{ maze[xstart][ystart]=maze[row -1][col+1];
   printMaze();
}


PLEASE USE CODE TAGS (the <> formatting button) when posting code.



ohk thank you :)
Topic archived. No new replies allowed.