Q: Modifying 2D array of char in void func

I'm currently stuck on a problem where I am passing a 2D array of char and trying to modify its values, but my function is designed to return a bool; So I'm running into the issue of not being able to assign a character to an element in the array because the elements are a const char* on lines 15 and 32.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
bool SolveMaze(char maze[][81], int row, int col, int i, int j)
{
	if(i > row || i < 0 || j > col || j < 0) // are we outside the maze?
	{
		return false;
	}
	if( i == row - 1 && j == col - 1 ) // are we at the end?
	{
		return true;
	}
	if( maze[i][j] == "*" || maze[i][j] == "@" || maze[i][j] == "#" ) // is it open?
	{
		return false;
	}
	maze[i][j] = "#"; // mark current location
	if(SolveMaze(maze, row, col, i - 1, j) == true) // can I go up?
	{
		return true;
	}
	if(SolveMaze(maze, row, col, i, j + 1) == true) // can I go right?
	{
		return true;
	}
	if(SolveMaze(maze, row, col, i + 1, j) == true) // can I go down?
	{
		return true;
	}
	if(SolveMaze(maze, row, col, i, j - 1) == true) // can I go left?
	{
		return true;
	}
	maze[i][j] = "@";
	return false;
}

int main(int argc, char *argv[])
{
	char maze[24][81];
	int row, col;
	int i = 0, j = 0;
		
	if(SolveMaze(maze, row, col, i, j))
	{
		PrintMaze(maze, row, col, cout);
	}
	else
	{
		cout << "Didn't work." << endl;
	}
	return 0;
}
I cut out all the non-relevant code. The compiler is also saying that on line 11
 
if( maze[i][j] == "*" || maze[i][j] == "@" || maze[i][j] == "#" )
that I cannot compare between a pointer and an integer. This is a recursive backtracking function to solve a maze, so I want to be able to modify the maze as I am solving it and return a bool to determine if the maze is solved or not. Any help or suggestions on how to solve my problem would be appreciated. Thank you!
Last edited on
Use single quotes for single characters: '*'
Double quotes are for strings.
Wow, that's an embarrassing mistake. Thank you for opening my eyes. -_-
Last edited on
Topic archived. No new replies allowed.