Can anyone go through my code? (regarding arrays)

Pages: 12
So, I'm pretty much done making my Minesweeper game project and just wanna go through a few things


the last 2 things I gotta do is a leaderboard, and set it so that if theres no mine in the space chosen, then it outputs a 1,2 or 3 depending on how many spaces away from a mine you are (I'm really finding that part hard)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
  #include<iostream>
#include<iomanip>
#include <stdio.h>      
#include <stdlib.h>     
#include <time.h>
#include <ctime>
#include<fstream>
using namespace std;
unsigned int Time = time(0);
fstream leaderfile;
int minesweeper[8][8];
char game[8][8];
int minesetter; 
int mines=0;
int guesses=0;
int row, col;
char square = 178, mine = 153,flag=214, rowline=179,space=' ';
char userchoice;
char play_again;

void displaymenu()
{
	char option;
		do
		{
			
				cout<<setw(50)<<"Welcome to MINESWEEPER"<<endl<<endl;
				cout<<setw(40)<<"Main Menu"<<endl<<endl<<endl;
				cout<<setw(10)<< "Please Choose Your Difficulty Level"<<endl<<endl;
				cout<<setw(10)<<"1. Beginner - Grid is (8x8) with 10 mines"<<endl<<endl;
				cout<<setw(10)<<"2. Intermidiate - Grid is (16x16) with 40 mines"<<endl<<endl;
				cout<<setw(9)<<"3. Expert - Grid is (24x24) with 99 mines"<<endl<<endl;
				cout<<setw(10)<<"4. Leader Board"<<endl<<endl;
				cout<<setw(10)<<"5. How to Play Minesweeper."<<endl<<endl<<endl;
				cout<<setw(10)<<"Press Q to quit the game back to windows"<<endl;
				cout<<endl<<endl<<endl<<endl<<endl<<"by Scott Brooks& F'n' A Games"<<endl<<endl;
				cin>>option;
				cout<<endl;
				cin.ignore();
				switch(option)
				{
				case '1':playB();
						break;
				case '2':playI();
						break;
				case '3':playE();
						break;
				case '4':leader();
						break;
				case '5':
						break;
				case 'q':
						break;
				default:
					cout<<"Please Enter 1, 2, 3, 4, 5 or Q"<<endl;
			};
				
		
		}
while (option!='q');

}

void initialise()
{
	int row,col;
	for (row=0;row<8;row++)
		for(col=0;col<8;col++)
			game[row][col]=square;
}



void mine_set()
{ 
   
do
	{
		int r=rand()%8;
		int c=rand()%8;
		if (minesweeper[r][c] !=mine)
			{
			minesweeper[r][c]=mine;
			mines++;
			}
		
	}
		while (mines<10);
	
}


void drawGridB()
{    
	cout<<setw(18)<<"|0|1|2|3|4|5|6|7|"<<endl;
	
	
   for (row=0;row<8;row++)
	{
		cout<<setw(2)<<"------------------"<<endl;
		cout<<row<<rowline;
		for(col=0;col<8;col++)
			
		{
			
			cout<<game[row][col]<<rowline;
		}
			
		cout<<endl;
			
		}	
   cout<<setw(2)<<"------------------"<<endl<<endl;
}
	



void playB()
{	
	 int score = 0;
	 guesses=0; 
	 initialise();
	 mine_set();

	do
	{ 
		
		drawGridB();		
		cout<<endl<<setw(6)<<"Score = "<<score<<endl<<endl;
		cout<<setw(6)<<"Guesses = "<<guesses<<endl<<endl;
		cout << "Please enter the Vertical number" << endl;
		cin >> col;
		cout << "Now enter the Horizontal number" << endl;
		cin >> row;

			if (row>=8||col>=8)
			{
				cout << "You have entered an invalid choice." << endl;
			}
			else
			{
				cout << "Do you want to dig(d) or flag for a bomb here(f)?" << endl;
				cin >> userchoice;

			if (game[row][col]=space)
				{
					cout<<"You have entered a invalid choice"<<endl;
				}
			//else if (game[row][col]=flag);
			//	{
			//		cout<<"You will now Dig at these coordinates"<<endl;
			//		game[row][col]=space;
			//	}

			if (userchoice == 'd' && minesweeper[row][col]==mine||guesses==65)
			{
				cout << "BOOM!!" << endl;
				cout << "You have hit a mine" << endl;
				cout<<"Score = "<<score<<endl;
				cout<<"Guesses ="<<guesses<<endl;
				cout << "Please Play again" << endl;
				game[row][col]=mine;
			}
			else if (userchoice == 'd' && minesweeper[row][col] == 0)
					{
						game[row][col]=' ';
						guesses++;
						score++;
						cout<<userchoice<<endl;
						
					}
			else if(userchoice=='d'&&minesweeper[row][col]==1)
					{
						game[row][col]='1';
						score++;
						guesses++;
						cout<<userchoice<<endl;;
						cout<<endl<<setw(6)<<"Score = "<<score<<endl<<endl;
						cout<<setw(6)<<"Guesses = "<<guesses<<endl<<endl;
					}
			else if (userchoice=='d'&&minesweeper[row][col]==2)
					{
						game[row][col]='2';
						guesses++;
						score++;
						cout<<userchoice<<endl;
						cout<<endl<<setw(6)<<"Score = "<<score<<endl<<endl;
						cout<<setw(6)<<"Guesses = "<<guesses<<endl<<endl;
					}
			else if (userchoice=='d'&&minesweeper[row][col]==3)
					{
						game[row][col]='3';
						guesses++;
						score++;
						cout<<userchoice<<endl;
						cout<<endl<<setw(6)<<"Score = "<<score<<endl<<endl;
						cout<<setw(6)<<"Guesses = "<<guesses<<endl<<endl;
					}
				else if (userchoice == 'f')
						{
							game[row][col]=flag;
							guesses++;
							
						}
			drawGridB();
		}
  }
  while (guesses<64);


		if(guesses==mines)
			cout<<"Congratulations- You Win!!!!"<<endl<<endl;
		cout<<"would you like to play again? Yes or No"<<endl;
		cin>>play_again;
		if ("yes")
			playB();
		else if ("No")
			displaymenu();
}


/*void leader()
{
	fstream leaderfile ("leader.txt");

	char option;
	do
	{
		cout<<"1. Insert new Entry to Leaderboard"<<endl;
		cout<<"2. Display Leaderboard"<<endl;
		cout<<"Q Quits to Main Menu."<<endl;
		cin>>option;
		cout<<endl;
		cin.ignore();
		switch (option)
		{
			case '1':
				int name;
				int number;
					leaderfile.open("Leader.txt",ios::out);
					leaderfile<<"LeaderBoard: MINESWEEPER";
					cout<<"Please Enter your name and Score"<<endl;
					cin;
					leaderfile>>name;
					leaderfile>>number;
					leaderfile.close();

				break;

			case '2':
				leaderfile.open("Leader.txt",ios::in);
				leaderfile.close();
				break;
			//case '3': main();
				//break;

			default: 
				cout<<"Please enter option 1 or 2 to continue or Q to go back to the main menu"<<endl;
	}
	}
	
while (option!='q');
}*/





void main()//start of the program, fully compiled
{
		displaymenu();
		srand(time(NULL));
		system("pause");
	
}
Last edited on
uhh, your code looks... well, I don't like it, I added a few comments.
Also somewhere in the code you use the pure number 8.
What meaning does that number have?
You should give it a name :)

But congratulations for your project! :D

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
#include <iostream>
#include <iomanip>
#include <stdio.h>      
#include <stdlib.h>     
#include <time.h>
#include <ctime>
#include <fstream>
using namespace std;

// here: split the variables up in groups they belong
// only write 1 variable each line, to make it easier to read.
unsigned int Time = time(0);
fstream leaderfile;
int minesweeper[8][8];
char game[8][8];
int minesetter; 
int mines=0;
int guesses=0;
int row, col;
char square = 178, mine = 153,flag=214, rowline=179,space=' '; // use the caracter, not their ASCII number.
char userchoice;
char play_again;

void displaymenu()
{
    char option;
    do
    {
        cout<<setw(50)<<"Welcome to MINESWEEPER"<<endl<<endl;
        cout<<setw(40)<<"Main Menu"<<endl<<endl<<endl;
        cout<<setw(10)<< "Please Choose Your Difficulty Level"<<endl<<endl;
        cout<<setw(10)<<"1. Beginner - Grid is (8x8) with 10 mines"<<endl<<endl;
        cout<<setw(10)<<"2. Intermidiate - Grid is (16x16) with 40 mines"<<endl<<endl;
        cout<<setw(9)<<"3. Expert - Grid is (24x24) with 99 mines"<<endl<<endl;
        cout<<setw(10)<<"4. Leader Board"<<endl<<endl;
        cout<<setw(10)<<"5. How to Play Minesweeper."<<endl<<endl<<endl;
        cout<<setw(10)<<"Press Q to quit the game back to windows"<<endl;
        cout<<endl<<endl<<endl<<endl<<endl<<"by Scott Brooks& F'n' A Games"<<endl<<endl;
        cin>>option;
        cout<<endl;
        cin.ignore();
        switch(option)
        {
            case '1':playB();
                break;
// where are playI and playE?
            case '2':playI();
                break;
            case '3':playE();
                break;
            case '4':leader();
                break;
            case '5':
                break;
            case 'q':
                break;
            default:
                cout<<"Please Enter 1, 2, 3, 4, 5 or Q"<<endl;
        };
        
        
    }
    while (option!='q');
    
}

void initialise()
{
    int row,col;
    for (row=0;row<8;row++)
        for(col=0;col<8;col++)
            game[row][col]=square;
}



void mine_set()
{ 
    
    do
    {
        int r=rand()%8;
        int c=rand()%8;
        if (minesweeper[r][c] !=mine)
        {
            minesweeper[r][c]=mine;
            mines++;
        }
        
    }
    while (mines<10);
    
}


void drawGridB()
{    
    cout<<setw(18)<<"|0|1|2|3|4|5|6|7|"<<endl;
    
    
    for (row=0;row<8;row++)
    {
        cout<<setw(2)<<"------------------"<<endl;
        cout<<row<<rowline;
        for(col=0;col<8;col++)
            
        {
            
            cout<<game[row][col]<<rowline;
        }
        
        cout<<endl;
        
    }   
    cout<<setw(2)<<"------------------"<<endl<<endl;
}




void playB()
{   
    int score = 0;
    guesses=0; 
    initialise();
    mine_set();
    
    do
    { 
        
        drawGridB();        
        cout<<endl<<setw(6)<<"Score = "<<score<<endl<<endl;
        cout<<setw(6)<<"Guesses = "<<guesses<<endl<<endl;
        cout << "Please enter the Vertical number" << endl;
        cin >> col;
        cout << "Now enter the Horizontal number" << endl;
        cin >> row;
        
        if (row>=8||col>=8)
        {
            cout << "You have entered an invalid choice." << endl;
        }
        else
        {
            cout << "Do you want to dig(d) or flag for a bomb here(f)?" << endl;
            cin >> userchoice;
            
            if (game[row][col]=space)
            {
                cout<<"You have entered a invalid choice"<<endl;
            }
            //else if (game[row][col]=flag);
            //  {
            //      cout<<"You will now Dig at these coordinates"<<endl;
            //      game[row][col]=space;
            //  }
            
            if (userchoice == 'd' && minesweeper[row][col]==mine||guesses==65)
            {
                cout << "BOOM!!" << endl;
                cout << "You have hit a mine" << endl;
                cout<<"Score = "<<score<<endl;
                cout<<"Guesses ="<<guesses<<endl;
                cout << "Please Play again" << endl;
                game[row][col]=mine;
            }
            else if (userchoice == 'd' && minesweeper[row][col] == 0)
            {
                game[row][col]=' ';
                guesses++;
                score++;
                cout<<userchoice<<endl;
                
            }
            else if(userchoice=='d'&&minesweeper[row][col]==1)
            {
                game[row][col]='1';
                score++;
                guesses++;
                cout<<userchoice<<endl;;
                cout<<endl<<setw(6)<<"Score = "<<score<<endl<<endl;
                cout<<setw(6)<<"Guesses = "<<guesses<<endl<<endl;
            }
            else if (userchoice=='d'&&minesweeper[row][col]==2)
            {
                game[row][col]='2';
                guesses++;
                score++;
                cout<<userchoice<<endl;
                cout<<endl<<setw(6)<<"Score = "<<score<<endl<<endl;
                cout<<setw(6)<<"Guesses = "<<guesses<<endl<<endl;
            }
            else if (userchoice=='d'&&minesweeper[row][col]==3)
            {
                game[row][col]='3';
                guesses++;
                score++;
                cout<<userchoice<<endl;
                cout<<endl<<setw(6)<<"Score = "<<score<<endl<<endl;
                cout<<setw(6)<<"Guesses = "<<guesses<<endl<<endl;
            }
            else if (userchoice == 'f')
            {
                game[row][col]=flag;
                guesses++;
                
            }
            drawGridB();
        }
    }
    while (guesses<64);
    
    
    if(guesses==mines)
        cout<<"Congratulations- You Win!!!!"<<endl<<endl;
    cout<<"would you like to play again? Yes or No"<<endl;
    cin>>play_again;
    if ("yes")
        playB();
    else if ("No")
        displaymenu();
}


/*void leader()
{
    fstream leaderfile ("leader.txt");
    
    char option;
    do
    {
        cout<<"1. Insert new Entry to Leaderboard"<<endl;
        cout<<"2. Display Leaderboard"<<endl;
        cout<<"Q Quits to Main Menu."<<endl;
        cin>>option;
        cout<<endl;
        cin.ignore();
        switch (option)
        {
            case '1':
                int name;
                int number;
                    leaderfile.open("Leader.txt",ios::out);
                    leaderfile<<"LeaderBoard: MINESWEEPER";
                    cout<<"Please Enter your name and Score"<<endl;
                    cin;
                    leaderfile>>name;
                    leaderfile>>number;
                    leaderfile.close();
                    
                break;
                
            case '2':
                leaderfile.open("Leader.txt",ios::in);
                leaderfile.close();
                break;
            //case '3': main();
                //break;
                
            default: 
                cout<<"Please enter option 1 or 2 to continue or Q to go back to the main menu"<<endl;
    }
    }
    
while (option!='q');
}*/

void main()//start of the program, fully compiled
{
    srand(time(NULL)); // make that before displaymenu
    displaymenu();
    system("pause");
}
thanks, I've used some of the advice, the 8 was for the minesweeper array, I meant to put it as a local variable, its sorted now
Anyway, what is your question for that topic?
^^ I need the chosen square to tell the player how many spaces they are from a mine

and output that number instead of a blank space, Im not sure how to do that
-Check the squares 1 space away for a mine. If there is a mine, place a 1 in your square and break.
-Check the squares 2 spaces away... etc.

You're using a 2d array so it's quite easy to check the squares that are +1/-1 away in the horizontal and vertical directions. Just make sure you check if you are at the edge. i.e. If you're on square [4][0] then you don't want to check [4][-1] for mines!
when/how do I do that?

for example, just off the top of my head here:

1
2
3
4
5
6
7
8
9
10
11

else if (userchoice == 'd' && minesweeper[row][col] == 0)
            {
               // (Do I check here?)
                game[row][col]=' ';
                guesses++;
                score++;
                cout<<userchoice<<endl;
                
            }
the best approach would be to make a better structure.

usually, when making a game you have this circle of operations:
Check Inputs -> Update -> Render

In your game, these operations aren't called with 60 fps but whenever you get new input.

Here is a little new, better structure of your code.
I left some functions undone, because you may want to implement them yourself :)
Please tell me if you don't understand something.

Note that it is essential in programming to have a good structured programm (Note: this is still far from beautiful but it's a good start :) )

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// some includes required

// global scope
bool quit = false;
bool playing = false;

enum {dig='d', flag='f'};
char operation;
int column;
int row;

enum { square=178, mine=153, flag=214, rowline=179, space=' ' };
int columns;
int rows;
char* map;

void input()
{
  do
  {
// didn't look at your code but i think this should be here
    cout<<endl<<setw(6)<<"Score = "<<score<<endl<<endl;
    cout<<setw(6)<<"Guesses = "<<guesses<<endl<<endl;

    cout << "Please enter the Vertical number (1 - " << col << ')' << endl;
    cin >> col; // enter col from 1 to columns
    --col;

    cout << "Now enter the Horizontal number (1 - " << rows << ')' << endl;
    cin >> row; // enter col from 1 to rows
    --row;

    if(!(col < columns && row < rows))
      std::cout << "please enter valid data" << std::endl;
    else
      break;
  } while(true);

  do
  {
    cout << "Do you want to dig(d) or flag for a bomb here(f)?" << endl;
    operation = getchar();
  } while(operation != dig && operation != flag)
}

void update()
{
  // you know the row and colum that is being opened next
  // do whatever needs to be done! :D
  // you need to do something when loosing to reset the playing boolean
}

void render()
{
  // render the current field :)
}

// NOTE: still need to implement the mines
void set_game(int row_cnt, int col_cnt, int mines)
{
// set map data
    rows = row_cnt; 
    columns = col_cnt;
    
// initialize map data
    map = new int[rows * columns];
    memset(map, square, rows*columns*sizeof(char)); // set data to default

// let's play!
    playing = true;
}

void leader()
{
}
void help()
{
}

void new_game()
{
  do
  {
    char option;

    cout<<setw(50)<<"Welcome to MINESWEEPER"<<endl<<endl;
    cout<<setw(40)<<"Main Menu"<<endl<<endl<<endl;
    cout<<setw(10)<< "Please Choose Your Difficulty Level"<<endl<<endl;
    cout<<setw(10)<<"1. Beginner - Grid is (8x8) with 10 mines"<<endl<<endl;
    cout<<setw(10)<<"2. Intermidiate - Grid is (16x16) with 40 mines"<<endl<<endl;
    cout<<setw(9)<<"3. Expert - Grid is (24x24) with 99 mines"<<endl<<endl;
    cout<<setw(10)<<"4. Leader Board"<<endl<<endl;
    cout<<setw(10)<<"5. How to Play Minesweeper."<<endl<<endl<<endl;
    cout<<setw(10)<<"Press Q to quit the game back to windows"<<endl;
    cout<<endl<<endl<<endl<<endl<<endl<<"by Scott Brooks& F'n' A Games"<<endl<<endl;

    cin>>option;
    cout<<endl;
    cin.ignore();

    switch(option)
    {
    case '1': set_game(8, 8, 10);
        break;
    case '2': set_game(16, 16, 40);
        break;
    case '3': set_game(24, 24, 99);
        break;
    case '4': leader();
        break;
    case '5': help();
        break;
    case 'Q':
        quit = true;
        playing = false;
        break;
    default:
        cout<<"Please Enter 1, 2, 3, 4, 5 or Q"<<endl;
    }
  } while(playing != true && quit != false);
}

void init() 
{
    // load media (not needed, your's is text-based)
    // start screen (not needed, you allways ask when a new game is played)
    // set random seeds
    srand(time(0));
}

int main(void)
{
    init(); // initializes the game

    while(!quit)
    {
        new_game();
        
        while(playing)
        {
            input();
            update();
            render();
        }
    }
}
Last edited on
1
2
3
4
5
6
7
8
9
else if (userchoice == 'd' && minesweeper[row][col] == 0)
            {
               // (Do I check here?)
                game[row][col]=' ';
                guesses++;
                score++;
                cout<<userchoice<<endl;
                
            }


Yes. You can do what you want with a for loop.
1
2
3
4
5
6
7
8
9
10
for(i = 0; i < n; ++i) //Where n is the max amount of spaces away you can 'see' mines. 
{
    if(game[row][col - i] = 153; 
    {
        //Mark your square as 1 and break out of the for loop. 
    }
    if(game[row][col + i] = 153

etc... 
}


Just make sure to only execute those if statements if col + i or row + i is not larger than your grid, and col - i and row - i are not below zero.

Btw, use "\n" rather than endl (go on Google if you're curious why).
Last edited on
^^Ok thanks, I think I've got it, the issue I've got now, is that I've moved all the arrays to be local variables and now it cannot compile

though its telling me it's something to do with the menu procedure
Last edited on
Are you making sure to pass those arrays around the functions?

What are the compiler errors (quote them!)?
1. not sure what you mean? I've moved them to be local variables and thats it

2. the errors listed are:

Error 7 error C1075: end of file found before the left brace '{' at ' line 566(my code ends at line 565!)

Error 3 error C3861: 'menu': identifier not found at line 263 (I have this error for all 3 difficulties)

9 IntelliSense: identifier "menu" is undefined at line364
^^ with this one, I changed all displaymenu() to just menu, but it had the same same error anyway


C1075: end of file found before the left brace '{' at ' line 566


now it's just this one left, I don't quite get it
1
2
3
4
5
6
7
8
9
10
11
12
Yes. You can do what you want with a for loop. 

for(i = 0; i < n; ++i) //Where n is the max amount of spaces away you can 'see' mines. 
{
    if(game[row][col - i] = 153; 
    {
        //Mark your square as 1 and break out of the for loop. 
    }
    if(game[row][col + i] = 153

etc... 
}


what is i? I'm assume its row?(I've seen a lot of people use i &j for rows and columns)
i is just an integer...
int i;

Edit: Are all your braces matching? Do all functions have a start and end brace?
Last edited on
Yea, I went through them all, it's only after I moved the void menu() I'll have a second look

so where do I callint i ?
Solved it!, it was a issue when I'd copied it from notepad++ it missed a closing brace, now I need to add this new part
Last edited on
int i is just reserving space for an integer. It's not something you 'call' but is space you need to reserve before using i.

You should read through this: http://www.cplusplus.com/doc/tutorial/variables/

I also recommend using an IDE that highlights matching braces (e.g. Code::Blocks) because you will never encounter a mismatched brace error ever again!
ah cool, I'll include the code::blocks stuff on my next project thanks.



so, at the minute I have

1
2
3
4
5
6
7
8
9
10
11
12
13
14
for (i=0;i<8;i++)
			{
				if(game[row][col-see]=153)
				{
					game[row][col]='1';
				}
				if(game[row][col+see]=153)
				{
					game[row][col]=153;
				}
				if(game[row][col+see+see]=153)
				{
					game[row][col]='3';
				} 


now this outputs '3' no matter where I place it, but it clears squares around it as well, where am I going wrong? I placed it within the do loop btw
"=" is assignment. "==" is comparison. i.e. In if statements (or anywhere else you are comparing values) you want to use "==".

Furthermore, the code you quoted shows a brace mis-match (no matching brace for line 2. Is that existing in your current code too?
Pages: 12