Recurrsion Maze

im having trouble implementing a loop to read the starting points from a text file allowing the user to answer if those are to points they want to use below I have them already hard coded in for testing purposes i was thinking using something like mazeEscape(maze,Num>9[0], using the elements of the 2D array but I'm not sure I believe my syntax may be off

this is the text file Im trying to read from



+ + +++ ++
+ + ++
+ +++++
+ +++++
+ ++ +
+ + +++ +
+ + ++++ E
+++ +
++++++++++
0 3
1 1
4 1
6 1
6 3


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
  
void printMaze(char maze[ROWS][COLS], int row, int col)
{
	for (int row = 0; row < ROWS; row++)
	{
		for (int col = 0; col < COLS; col++)
		{
			cout << maze[row][col] << ' ';
		}
		cout << endl;
	}
	cout << "Press Enter to continue";
	cin.get();
	cout << endl;
}

int main()
{

	char maze[ROWS][COLS];

	string filename;
	string line;
	int Num = 0;
	int startingRow = 0;
	int startingCol = 0;
	cout << " Please Select a Maze ";
	getline(cin, filename);
	ifstream file(filename, ios::in);
	if (file.is_open()) 
	{
		for (int row = 0; row < ROWS; row++) 
		{
			getline(file, line);
			for (int col = 0; col < COLS; col++)
			{
				
				maze[row][col] = line[col];
			}
		}
	}
	
	
	if (mazeEscape(maze, 1, 1))//hardcoded starting points that work
		cout << "horray I'm Free" << endl;
	else
		cout << "Help Im Trapped" << endl;

	system("pause");
	return 0;
Last edited on
Topic archived. No new replies allowed.