Trying to use 2D string array, but having compile errors

I am trying to use a 2D array and pass it through to a function that will let me print the array to the console. In other words, at this stage I just want to be able to print the array and see if it works, the data within the array doesn't matter right now. However, I am getting compile errors about pointer type and it is based all on one line.

Here is the code:

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
52

void msgBoard(char msgBoard[20][2]);

void printmsgBoard(char msgBoard[20][2]) 
{

	for (int i = 0; i < 20; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			cout << " " << msgBoard[i][j];
		}
		cout << endl;
		cout << "Positon: " << i << endl;
	}
	cout << endl;

}

//This is the start of halfway through part of my code

	while (choice != "4")
	{
		getline(cin, choice);
		if (choice == "1")
		{
			subMenu1();
		}
		else if (choice == "2")
		{
			subMenu2();
		}
		else if (choice == "3") 
		{
			printmsgBoard(msgBoard);
		}
		else if (choice == "4")
			cout << "Quit" << endl;
	}

}



int main()
{
	char msgBoard[20][2];
	
	mainMenu();

    return 0;
}
Please copy and paste the exact error message and indicate which line it is referring to.

I'd guess the issue is that you are not passing the msgBoard to your mainMenu function and so it can't pass it on to other functions.
Last edited on
Topic archived. No new replies allowed.