Multi Dimensional Array help

aaa
Last edited on
I'm not sure what the 'minesweeper[row][col] part' is.

Line 25 is of course wrong. It needs to be:

(minesweeper[row][col]==0) || (minesweeper[row][col]==1) || ...

I suggest that the constant value is written first:

(0 == minesweeper[row][col]) || (1 == minesweeper[row][col]) || ...

So line 32 wouldn't be a problem (the compiler would complain).

Line 32: userchoice='f' // This assigns 'f' to userchoice and does not compare
sorry the minesweeper[row][col] is a int array with a pre-determined field of mines, -1 is a mine, o,1,2,3 are not mines.
I guess that:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
			if(userchoice='d')
				if (userchoice=='d'&&minesweeper[row][col]==-1)
				{
					cout<<"BOOM!!"<<endl;
					cout<<"You have hit a mine"<<endl;
					cout<<"Please Play again"<<endl;
					cout<<minesweeper[row][col];
					break;
				}
				else if (userchoice=='d'&&minesweeper[row][col]==0||1||2||3)
				{
					game[row][col]=minesweeper[row][col];
					guesses++;
					score++;
					cout<<score<<endl;
				}
				else if (userchoice='f')
				{
					game[row][col]=flag;
				}
could be written as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
			if(userchoice=='d') // Note == not =
			{
				if (minesweeper[row][col]==-1)
				{
					cout<<"BOOM!!"<<endl;
					cout<<"You have hit a mine"<<endl;
					cout<<"Please Play again"<<endl;
					cout<<minesweeper[row][col];
					break;
				}
				else
				{
					game[row][col]=minesweeper[row][col];
					guesses++;
					score++;
					cout<<score<<endl;
				}
			}
			else if (userchoice=='f') // Note: ==
			{
				game[row][col]=flag;
			}
thanks, but I now cannot get that to display anything but the char array gameplay[row][col] so none of the minesweeper array is being revealed
Topic archived. No new replies allowed.