Checkers Access Violation

Is there anything wrong with the below code? I am getting an access violation, and I think it has something to do with the last two lines
of code. Basically I am trying to update this board array with a blank
value where the user selected a board piece, and based on their destination
selection, the piece will be placed there.

Ex.
Selection: A3 piece original location, will be empty after move
Destination: B3 piece moved here

Char a, b, c, and d are all numbers. I have a function that converts them
letter to a number.

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

void displayBoard(char a, char b, char c, char d) {
	//delete the below array, and make a new one with the passed in values.

	//a is destination column
	//b is desination row
	//c is selection column
	//d is selection row

	//board[a][b] = NULL
	//board[c][d] = B or W




	char board[9][8] = {
		{ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' },
		{ 'B', ' ', 'B', ' ', 'B', ' ', 'B', ' ' },
		{ ' ', 'B', ' ', 'B', ' ', 'B', ' ', 'B' },
		{ 'B', ' ', 'B', ' ', 'B', ' ', 'B', ' ' },
		{ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
		{ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
		{ 'W', ' ', 'W', ' ', 'W', ' ', 'W', ' ' },
		{ ' ', 'W', ' ', 'W', ' ', 'W', ' ', 'W' },
		{ 'W', ' ', 'W', ' ', 'W', ' ', 'W', ' ' },
	};
	cout << "Dest & Selection after Function " << endl;
	cout << a << " dest column " << endl;
	cout << b << " dest row " << endl;
	cout << c << " selection column " << endl;
	cout << d << " selection row " << endl;
	board[a][b] = 'B'; //at this position, change to B
	board[c][d] = ' ';//at this position, change to ' '
Last edited on
It is something to do with the last two lines of code, I have commented them out and it runs fine
Solved, for anyone wondering, board[a][b] need to be of not type char.
Topic archived. No new replies allowed.