Unhandled exception?
May 21, 2015 at 4:59am UTC
I appear to get this strange error which I can't solve, could someone please help me?
Error: Unhandled exception at 0x2e232e23 in Game.exe: 0xC0000005: Access violation.
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
#include <iostream>
#include <string>
using namespace std;
int i,y;
char board[8][8];
class Checkers {
public :
void setBoard() {
for (i=0; i < 8; i++){
for (y=0; i< 8; y++) {
if ((i+y)%2==0) {
board[i][y] = '#' ;}
else {
board[i][y] = '.' ;
}
}
}
}
void printBoard() {
for (i=0;i<8;i++) {
for (y=0;y<8;y++) {
cout << board[i][y];
}
cout << endl;
}
}
};
int main() {
Checkers Checks;
Checks.setBoard();
Checks.printBoard();
cin.get();
return 0;
}
May 21, 2015 at 5:52am UTC
for (y=0; i< 8; y++)
^ Problem.
May 22, 2015 at 4:30am UTC
On line 11...
Also, I don't see why i, y, or board need to be globals?
Andy
May 23, 2015 at 3:48am UTC
I was trying to debug it, during the process I made i and y global as an attempt to debug it.
Topic archived. No new replies allowed.