Struggling with C++ Minesweeper Game

Pages: 1234
I have made the intermediate level of the game that requires a grid of 16x16 and 40 mines the only problem is that due to the numbers going into double figures the grid doesn't line up with the numbers, is there a trick to line it up or do I just add more spaces?
You could do something like this (using NwN's 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
void display_board(char** board, int rows, int columns)
{    
    // printing the first row here
    cout << "  ";
    for (int i=0; i<colums; i++)  //make a number for every column (notice '8' is changed to 'columns' here)
        if (i<=9) { cout << " " << i; } //prints space and number
        else { cout << i; }             //prints 2-digit number

    for (int r=0; r<rows; r++) 
    {
        /* as for our Y axis numbers, we want them at the start of every row
         * so we put them before we start generating dots or dashes
         * we can use the counter of the row-loop as the actual numbers: */
        if (r<=9) { cout << " " << r; } //prints space and number
        else { cout << r; }             //prints 2-digit number

        for (int c=0; c<columns; c++)
        {
            if (board[r][c] == 'e')
            { cout<<"- ";} //dash if guessed and no bomb
            else if (board[r][c] == 'x')
            {cout<<"X ";} // X marks a marked bomb
            else
            { cout<<". ";} //point if not guessed, or if bomb
        }
        
        cout<<endl;
    }
}
Last edited on
closed account (o3hC5Di1)
Yes, AbR was right. With all the copying of code it was getting a bit confusing what to change when and where sometimes.

Now, as for your leaderboard:

hillkidstr wrote:
1
2
3
char name;
cout << "Please enter your name for the leaderboard"
cin >> name >> endl;


Nearly correct:

1
2
3
char name;  //don't use char here, that only contains one character, you need a string for this
cout << "Please enter your name for the leaderboard";
cin >> name; >> endl; //endl outputs a newline, here we have input  


After asking and storing the name your next steps would be the following:

- open the leaderboard file
- read its contents into a variable type which will allow you to sort by score
- insert current name and score in there
- resort the variable type
- write it back to the file


I would suggest you to take this into two separate functions, one for reading the file and one for writing (because you also want to read the file when you want to display the leaderboard in menu option 4, without writing anything to it).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<some datatype> read_leaderboard()
{
    <some datatype> leaderboard_data;
    //read file contents into leaderboard_data;
    return leaderboard_data;
}

void write_leaderboard(string name, int score)
{
    <some datatype> leaderboard = read_leaderboard();
    //insert name and score into leaderboard
    //re-sort leaderboard, maybe trim to first 10 entries as "high scores"
    //write leaderboard back to file
}


Unfortunately I'm afraid I can't help you with this because I haven't really learnt about reading/writing files right now, nor about a datatype that will fit this purpose (hence the "<some datatype>"). I read vectors are often used for similar things, but I'm not familiar with them yet.

I would suggest you to create a new topic on the forum on the sole purpose of the leaderboard issue. Feel free to copy any of the "code" in this post to explain your point.

Let me know if there's anything else you might need help on.
Sorry I can't help you out on this one.

All the best and thanks for cooperating so patiently, I do believe it's a better way to learn than just getting the solution from someone.

NwN
Last edited on
NwN there's no need to be sorry, you have helped me get this nearly 100% complete, your the one with the patients lol.

AbR you have also been a great help :D just wish I had signed up to this forum sooner.

I have changed the code to what AbR has said and on the row of numbers it gets to 8 and then the numbers are really close together a bit like this,

1 2 3 4 5 6 7 8 910111213141516 0........

thats pretty much exactly how it looks.

Thanks
closed account (o3hC5Di1)
Ah yes, I overlooked that part.
I've added some bits to counteract that, I think you'll like it:

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
void display_board(char** board, int rows, int columns)
{    
    int linecharacters = 0;
    char vlign = '|';
    char hlign = '_';
    // printing the first row here
    cout << "  |";
    linecharacters += 3;
    for (int i=0; i<columns; i++)
    {
        cout << i;
        if (i<=9) 
        {
            cout << " ";
            linecharacters++;
        }
        cout << "|";
        linecharacters += (i > 9) ? 3 : 2; 
    }
    cout << endl;

    string line = string(linecharacters, hlign);
    for (int r=0; r<rows; r++) 
    {
        cout << line << endl;
        /* as for our Y axis numbers, we want them at the start of every row
         * so we put them before we start generating dots or dashes
         * we can use the counter of the row-loop as the actual numbers: */
        if (r<=9) { cout <<  r << " " << vlign; } //prints space and number
        else { cout << r << vlign; }             //prints 2-digit number

        for (int c=0; c<columns; c++)
        {
            if (board[r][c] == 'e')
            { cout<<"- "<<vlign;} //dash if guessed and no bomb
            else if (board[r][c] == 'x')
            {cout<<"X "<<vlign;} // X marks a marked bomb
            else
            { cout<<". "<<vlign;} //point if not guessed, or if bomb
        }
        
        cout<<endl;
    }
}


I didn't comment the code this time, if yu want to make sure you understand maybe have a look and try to tell us what you think the added code does :)

All the best,
NwN
Last edited on
I know I know lol

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
void display_board(int rows, int columns)
{    
    int linecharacters = 0;
    char vlign = '|'; //these create a grid
    char hlign = '_';
    // printing the first row here
    cout << "  |";
    linecharacters += 3;
    for (int i=0; i<columns; i++)
    {
        cout << i;
        if (i<=9) 
        {
            cout << " ";
            linecharacters++;
        }
        cout << "|";
        linecharacters += (i > 9) ? 3 : 2; 
    }
    cout << endl;

    string line = string(linecharacters, hlign);
    for (int r=0; r<rows; r++) 
    {
        cout << line << endl;
        /* as for our Y axis numbers, we want them at the start of every row
         * so we put them before we start generating dots or dashes
         * we can use the counter of the row-loop as the actual numbers: */
        if (r<=9) { cout <<  r << " " << vlign; } //prints space and number
        else { cout << r << vlign; }             //prints 2-digit number

        for (int c=0; c<columns; c++)
        {
            if (board[r][c] == 'e')
            { cout<<"- "<<vlign;} //dash if guessed and no bomb
            else if (board[r][c] == 'x')
            {cout<<"X "<<vlign;} // X marks a marked bomb
            else
            { cout<<". "<<vlign;} //point if not guessed, or if bomb
        }
        
        cout<<endl;
    }
}


the only problem is it wont run :( If i am right I think it is missing char** board from the void section.

Once added the only problem is the cout << line << endl; which is causing it not to run because of the <<.

Any ideas?

Thanks
closed account (o3hC5Di1)
Hi there,

Yes indeed, char**board should have been added there, i took it out to test it here quickly, sorry!

Strange that it doesn't print the line!
Try adding #include <string> at the top of your file.

If that doesn't work, can you post your entire code + error once again please, because this function runs perfectly on my pc as I posted it.

All the best,
NwN
Last edited on
Its Kk i thought you where testing me lol

the error for that has now gone and is now with the rows, here is the code :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
// Minesweeper 4.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <ctime>
#include <string>
using namespace std;

int score = 0;
int X,Y;
char name;

/* we take out the functionality of displaying the board
** this way we can display beginner/intermediate/... boards
** with just this function.*/
void display_board(char** board, int rows, int columns)
{    
    int linecharacters = 0;
    char vlign = '|';
    char hlign = '_';
    // printing the first row here
    cout << "  |";
    linecharacters += 3;
    for (int i=0; i<columns; i++)
    {
        cout << i;
        if (i<=9) 
        {
            cout << " ";
            linecharacters++;
        }
        cout << "|";
        linecharacters += (i > 9) ? 3 : 2; 
    }
    cout << endl;

    string line = string(linecharacters, hlign);
    for (int r=0; r<rows; r++); 
    {
        cout << line << endl;
        /* as for our Y axis numbers, we want them at the start of every row
         * so we put them before we start generating dots or dashes
         * we can use the counter of the row-loop as the actual numbers: */
        if (r<=9) { cout <<  r << " " << vlign; } //this line is the error
        else { cout << r << vlign; }             //prints 2-digit number

        for (int c=0; c<columns; c++)
        {
            if (board[r][c] == 'e')
            { cout<<"- "<<vlign;} //dash if guessed and no bomb
            else if (board[r][c] == 'x')
            {cout<<"X "<<vlign;} // X marks a marked bomb
            else
            { cout<<". "<<vlign;} //point if not guessed, or if bomb
        }
        
        cout<<endl;
    }
}

/* we take out the functionality of playing i.e. marking fields,
** again so that this can apply to all levels */
void play_board(char** board, int rows, int columns, int mines)
{
    int guessed_mines = 0; //keep track of number of correctly guessed mines
    int X, Y;   //user specified X/Y coordinates
    char userchoice;
    
    //we need to do the following in a loop until either the player hits a bomb
    //or the player finds the mines and wins the game
    do
    {
        display_board(board, rows, columns);

        cout<<"Enter X Co-ordinate (1-8)"<<endl;
    	cin>>X;
    	cout<<"Enter Y Co-ordinate (1-8)"<<endl;
    	cin>>Y;
    	cout<<"Enter M to make move, B to mark as bomb"<<endl;
    	cin>>userchoice;
    	if (Y>rows||X>columns)
    	    cout << "You have entered the wrong Co-ordinates, Please Retry" << endl;

        //if user choses Move and hits a bomb, game ends
	    if (userchoice=='m' && board[X][Y] == 'b')
	    {
            cout << "Boom! Sorry, you lost this game. Better luck next time!" <<endl;
			cout << "Your total score for this game is : ";
            break;
        }
        //if user choses mark Bomb on a bomb field, set value to x
	    else if (userchoice=='b' && board[X][Y] == 'b') 
	    {
            board[X][Y] = 'x';
            guessed_mines++;
			score = score + 10;
        }         
        //possibly you may want to add a check when user marks bomb but field is empty.
	    //if field is empty and not already marked as bomb, mark as [e]mpty.
        else
	    {
            if (board[X][Y] != 'x') board[X][Y] = 'e';
			++score;
        }
    } while (guessed_mines < mines);
    
    //if the number of guessed mines is indeed the number of mines in the board, win
    if (guessed_mines == mines)
    {
        cout << "You won!" << endl;
        //you can insert a question here like "play again? next level?"
    }
}


void set_mines(char** board, int columns, int rows, int mines)
{ 
    int minecounter = 0, X, Y;
	do
	{
		X = rand()%rows;   //we use rows and columns passed in the
                Y = rand()%columns; //parameters so it will work in whatever level we use this
                if (board[X][Y] !='b')
		{
			board[X][Y] = 'b'; //Assign the bomb
			minecounter++;
		}
	} while (minecounter < mines);
}

void beginner() { //Beginner

    int rows=8, columns=8, mines=99;

	cout << "You have selected to play the Beginner level of minesweeper, Good Luck!" << endl;
	//declare and fill the board matrix, can't use regular array as we're passing
    //this to functions, don't worry about it now, just know this is an ugly quickfix.
	char** beginnerboard = new char *[rows];  
    for (int i=0;i<rows;i++)
    {
        beginnerboard[i] = new char[columns];
    }
    //assign bombs by putting the letter "b" in certain fields of our board
	set_mines(beginnerboard, rows, columns, mines);
	
	
    
    //play the game
    play_board(beginnerboard, rows, columns, mines);
	cout<<score<<endl;
    system ("pause");
    delete[] beginnerboard;
}

void intermediate() { //Intermediate

    int rows=16, columns=16, mines=40;

	cout << "You have selected to play the Intermediate level of minesweeper, Good Luck!" << endl;
	//declare and fill the board matrix, can't use regular array as we're passing
    //this to functions, don't worry about it now, just know this is an ugly quickfix.
	char** intermediateboard = new char *[rows];  
    for (int i=0;i<rows;i++)
    {
        intermediateboard[i] = new char[columns];
    }
    //assign bombs by putting the letter "b" in certain fields of our board
	set_mines(intermediateboard, rows, columns, mines);
	
	
    
    //play the game
    play_board(intermediateboard, rows, columns, mines);
	cout<<score<<endl;
    system ("pause");
    delete[] intermediateboard;
}

void expert() { //Intermediate

    int rows=24, columns=24, mines=576;

	cout << "You have selected to play the Intermediate level of minesweeper, Good Luck!" << endl;
	//declare and fill the board matrix, can't use regular array as we're passing
    //this to functions, don't worry about it now, just know this is an ugly quickfix.
	char** expertboard = new char *[rows];  
    for (int i=0;i<rows;i++)
    {
        expertboard[i] = new char[columns];
    }
    //assign bombs by putting the letter "b" in certain fields of our board
	set_mines(expertboard, rows, columns, mines);
	
	
    
    //play the game
    play_board(expertboard, rows, columns, mines);
	cout<<score<<endl;
    system ("pause");
    delete[] expertboard;
}


void leaguetable() //Table
{
	system("cls");
	cout << "This is the League Table" << endl;
	system ("pause");
}

void displayMenu() //Menu
{
        char choice;

        system("cls");
        cout << "Welcome to Minesweeper!" << endl;
        cout << "1.Beginner" << endl;
        cout << "2.Intermediate" << endl;
        cout << "3.Expert" << endl;
        cout << "4.League Table" << endl;
        cout << "5.Exit" << endl;
        cout << "Please enter your menu choice: ";
        cin >> choice;

        switch (choice)
        { 
                case '1' : 
                    beginner(); 
                    break;
                case '2' :
					intermediate();
						break;
                case '3' : 
					expert();
						break;
                case '4' : leaguetable();
                           break;
                case '5' : cout << "Thanks for playing minesweeper" << endl;
                           break;

                default :
                       cout << "Please enter a value between 1 and 5" << endl;
                       system ("pause");
                          
        }
}


int main() 
{
	srand(time(NULL));
    displayMenu();
    system("pause");
    return 0;
}


What I have made bold and underlined is the error it states this, Error: identifier 'r' is undefined.

Last edited on
If you declare int r before the for-loop it compiles. I can't tell you why though :(

1
2
3
4
5
6
7
    ...
    string line = string(linecharacters, hlign);
    int r;
    for (r=0; r<rows; r++);
    {
        cout << line << endl;
    ...


But even though it compiles, only the start of the program seems to run. I'll try and have a closer look at the code.
Last edited on
Take a good look at that line again. Maybe look for an out-of-place semi-colon.
Right - thanks.

I usually leave the starting brace at the end of the loop line like this:
1
2
3
for (r=0; r<rows; r++) {
    code;
}

... to avoid putting a semi-colon by mistake.

1
2
3
4
5
6
7
    ...
    string line = string(linecharacters, hlign);
    int r; //this could go back into the for-loop
    for (r=0; r<rows; r++); //<- lose the semi-colon here
    {
        cout << line << endl;
    ...


edit - additional comments
line 134
int rows=8, columns=8, mines=99; //you can't fit that many mines on your board

You ask user to "Enter X Co-ordinate (1-8)", but your board uses figures 0-7. If player enters 8 the program will fail, since board[8][n] doesn't exist.
0-7 also equals the figures used to identify individual rows and colums.
Last edited on
The mines part is my fault was doing some random tests was meant to be 10, 40, 99 which I have now changed thanks for all this help.

cire or AbR you wouldn't know how I would create a leaderboard would you?

Thanks
Right I have altered everything that i think needs altering, this is my code but it crashes when I select a level.

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
// Minesweeper 4.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <ctime>
#include <string>
using namespace std;

int score = 0;
int X,Y;
char name;

/* we take out the functionality of displaying the board
** this way we can display beginner/intermediate/... boards
** with just this function.*/
void display_board(char** board, int rows, int columns)
{    
    int linecharacters = 0;
    char vlign = '|';
    char hlign = '_';
    // printing the first row here
    cout << "  |";
    linecharacters += 3;
    for (int i=0; i<columns; i++)
    {
        cout << i;
        if (i<=9) 
        {
            cout << " ";
            linecharacters++;
        }
        cout << "|";
        linecharacters += (i > 9) ? 3 : 2; 
    }
    cout << endl;

    string line = string(linecharacters, hlign);
	int r;
    for (r=0; r<rows; r++); 
    {
        cout << line << endl;
        /* as for our Y axis numbers, we want them at the start of every row
         * so we put them before we start generating dots or dashes
         * we can use the counter of the row-loop as the actual numbers: */
        if (r<=9) { cout <<  r << " " << vlign; } //prints space and number
        else { cout << r << vlign; }             //prints 2-digit number

        for (int c=0; c<columns; c++)
        {
            if (board[r][c] == 'e')
            { cout<<"- "<<vlign;} //dash if guessed and no bomb
            else if (board[r][c] == 'x')
            {cout<<"X "<<vlign;} // X marks a marked bomb
            else
            { cout<<". "<<vlign;} //point if not guessed, or if bomb
        }
        
        cout<<endl;
    }
}

/* we take out the functionality of playing i.e. marking fields,
** again so that this can apply to all levels */
void play_board(char** board, int rows, int columns, int mines)
{
    int guessed_mines = 0; //keep track of number of correctly guessed mines
    int X, Y;   //user specified X/Y coordinates
    char userchoice;
    
    //we need to do the following in a loop until either the player hits a bomb
    //or the player finds the mines and wins the game
    do
    {
        display_board(board, rows, columns);

        cout<<"Enter X Co-ordinate"<<endl;
    	cin>>X;
    	cout<<"Enter Y Co-ordinate"<<endl;
    	cin>>Y;
    	cout<<"Enter M to make move, B to mark as bomb"<<endl;
    	cin>>userchoice;
    	if (Y>rows||X>columns)
    	    cout << "You have entered the wrong Co-ordinates, Please Retry" << endl;

        //if user choses Move and hits a bomb, game ends
	    if (userchoice=='m' && board[X][Y] == 'b')
	    {
            cout << "Boom! Sorry, you lost this game. Better luck next time!" <<endl;
			cout << "Your total score for this game is : ";
            break;
        }
        //if user choses mark Bomb on a bomb field, set value to x
	    else if (userchoice=='b' && board[X][Y] == 'b') 
	    {
            board[X][Y] = 'x';
            guessed_mines++;
			score = score + 10;
        }         
        //possibly you may want to add a check when user marks bomb but field is empty.
	    //if field is empty and not already marked as bomb, mark as [e]mpty.
        else
	    {
            if (board[X][Y] != 'x') board[X][Y] = 'e';
			++score;
        }
    } while (guessed_mines < mines);
    
    //if the number of guessed mines is indeed the number of mines in the board, win
    if (guessed_mines == mines)
    {
        cout << "You won!" << endl;
        //you can insert a question here like "play again? next level?"
    }
}


void set_mines(char** board, int columns, int rows, int mines)
{ 
    int minecounter = 0, X, Y;
	do
	{
		X = rand()%rows;   //we use rows and columns passed in the
                Y = rand()%columns; //parameters so it will work in whatever level we use this
                if (board[X][Y] !='b')
		{
			board[X][Y] = 'b'; //Assign the bomb
			minecounter++;
		}
	} while (minecounter < mines);
}

void beginner() { //Beginner

    int rows=8, columns=8, mines=10;

	cout << "You have selected to play the Beginner level of minesweeper, Good Luck!" << endl;
	//declare and fill the board matrix, can't use regular array as we're passing
    //this to functions, don't worry about it now, just know this is an ugly quickfix.
	char** beginnerboard = new char *[rows];  
    for (int i=0;i<rows;i++)
    {
        beginnerboard[i] = new char[columns];
    }
    //assign bombs by putting the letter "b" in certain fields of our board
	set_mines(beginnerboard, rows, columns, mines);
	
	
    
    //play the game
    play_board(beginnerboard, rows, columns, mines);
	cout<<score<<endl;
    system ("pause");
    delete[] beginnerboard;
}

void intermediate() { //Intermediate

    int rows=16, columns=16, mines=40;

	cout << "You have selected to play the Intermediate level of minesweeper, Good Luck!" << endl;
	//declare and fill the board matrix, can't use regular array as we're passing
    //this to functions, don't worry about it now, just know this is an ugly quickfix.
	char** intermediateboard = new char *[rows];  
    for (int i=0;i<rows;i++)
    {
        intermediateboard[i] = new char[columns];
    }
    //assign bombs by putting the letter "b" in certain fields of our board
	set_mines(intermediateboard, rows, columns, mines);
	
	
    
    //play the game
    play_board(intermediateboard, rows, columns, mines);
	cout<<score<<endl;
    system ("pause");
    delete[] intermediateboard;
}

void expert() { //Intermediate

    int rows=24, columns=24, mines=99;

	cout << "You have selected to play the Intermediate level of minesweeper, Good Luck!" << endl;
	//declare and fill the board matrix, can't use regular array as we're passing
    //this to functions, don't worry about it now, just know this is an ugly quickfix.
	char** expertboard = new char *[rows];  
    for (int i=0;i<rows;i++)
    {
        expertboard[i] = new char[columns];
    }
    //assign bombs by putting the letter "b" in certain fields of our board
	set_mines(expertboard, rows, columns, mines);
	
	
    
    //play the game
    play_board(expertboard, rows, columns, mines);
	cout<<score<<endl;
    system ("pause");
    delete[] expertboard;
}


void leaguetable() //Table
{
	system("cls");
	cout << "This is the League Table" << endl;
	system ("pause");
}

void displayMenu() //Menu
{
        char choice;

        system("cls");
        cout << "Welcome to Minesweeper!" << endl;
        cout << "1.Beginner" << endl;
        cout << "2.Intermediate" << endl;
        cout << "3.Expert" << endl;
        cout << "4.League Table" << endl;
        cout << "5.Exit" << endl;
        cout << "Please enter your menu choice: ";
        cin >> choice;

        switch (choice)
        { 
                case '1' : 
                    beginner(); 
                    break;
                case '2' :
					intermediate();
						break;
                case '3' : 
					expert();
						break;
                case '4' : leaguetable();
                           break;
                case '5' : cout << "Thanks for playing minesweeper" << endl;
                           break;

                default :
                       cout << "Please enter a value between 1 and 5" << endl;
                       system ("pause");
                          
        }
}


int main() 
{
	srand(time(NULL));
    displayMenu();
    system("pause");
    return 0;
}


This was the error

Unhandled exception at 0x77ab15de in Mine Final.exe: 0xC0000005: Access violation reading location 0xfdfdfdfd.

Thanks
*coughsemi-coloncough*

for (r=0; r<rows; r++);
I feel like a prick now :(

Its all fully working :D just need a league table and then it is complete :D

Cant thank everyone enough for all of their help.
closed account (o3hC5Di1)
Hi there,

Good to hear you got it working! :)

As for the leaderboard, I'd suggest again to create a specific topic on that, as per my post http://cplusplus.com/forum/beginner/71799/4/#msg384737 .

I'll be following that thread to see how that works too.

All the best,
NwN
Topic archived. No new replies allowed.
Pages: 1234