Problems when trying to change values in an array

im trying to change the values of my array which is filled first by a constructor now i need to change this values however i cant can someone tell me what i doing wrong
board cpp
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
#include"board.h"
#include<iostream>
void Cboard::printboard(){
	int check ;
	std::cout<<" ";
for(i=65 ; i <73 ; i++){
	std::cout<<(char)i<<"-";
}

std::cout<<std::endl;
	for(i=0;i<8;i++){
		
		std::cout<<i+1<<"|";
		
		for(j=0;j<8;j++){
		
			ans =(i)+j;
			mod = ans%2;
			check = printpieces(board,i,j);
		if (check != 1){
			 if(mod == 0){
				
			std::cout<<(char)178;
			std::cout<<" ";
			
			}
			else if(mod !=0){
				
				std::cout<<(char)176;
			
			std::cout<<" ";
			}
			
			
		}
			
		}
		std::cout<<"|"<<i+1;
		
		std::cout<<std::endl;
}
	std::cout<<" ";
	for(i=65 ; i <73 ; i++){
		std::cout<<(char)i<<"-";

}

}
Cboard::Cboard(){
	
	board[0][0] = 3;
	board[0][1] = 5;
	board[0][2] = 7;
	board[0][3] = 9;
	board[0][4] = 11;
	board[0][5] = 7;
	board[0][6] = 5;
	board[0][7] = 3;
	
	for(i=0;i<8;i++){
	board[1][i] = 1;
	}
	for(i=0;i<8;i++){
	board[6][i] = 2;
	}
	board[7][0] = 4;
	board[7][1] = 6;
	board[7][2] = 8;
	board[7][3] = 10;
	board[7][4] = 12;
	board[7][5] = 8;
	board[7][6] = 6;
	board[7][7] = 4;
	

}
Cboard::~Cboard(){

}

int Cboard::printpieces(int board[8][8],int i, int j){
	int check = 0;
	if(board[i][j] == 1||board[i][j] == 2){
    std::cout<<"P"<<" ";
	check = 1;
	}
	else if(board[i][j] == 4||board[i][j] == 3){
    std::cout<<"R"<<" ";
	check = 1;
	}
	if(board[i][j] == 5||board[i][j] == 6){
    std::cout<<"N"<<" ";
	check = 1;
	}
	if(board[i][j] == 7||board[i][j] == 8){
    std::cout<<"B"<<" ";
	check = 1;
	}
	if(board[i][j] == 9||board[i][j] == 10){
    std::cout<<"Q"<<" ";
	check = 1;
	}
	if(board[i][j] == 11||board[i][j] == 12){
    std::cout<<"K"<<" ";
	check = 1;
	}
	return check ;
 
}// to print pieces 
int Cboard::getvalues(){
	return board[8][8];
}
void Cboard::setvalues(char location[], int *a,int *b){
	int  loc,loc1,loc2, loc3;
	char upper[5];
	int i=0;
	int old,old1,new1,new2;
	for( i=0;i<5;i++){
		upper[i] = toupper(location[i]);
	}
	loc = (int)upper[0];
	loc1= (int)upper[1];
	loc2 = (int)upper [2];
	loc3 = (int)upper[3];
	old =65-loc;
	old1= loc1-49;
	new1= 65- loc2;
	new2= loc3-49;
	board[old1][old]= 0;
	board[new2][new1] = 2;
	getvalues();

}


int Cboard::check(int board[8][8]){

name = board[i][j];
	return name;
}

main cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include<iostream>
#include"board.h"

void main(){
	char location[5];
	int a,b;
	int x=0;
	Cboard myboard;
	do{
	myboard.getvalues();
	myboard.printboard();
	std::cout<<"please enter location";
	std::cin>>location;
	myboard.setvalues(location,&a,&b);
	x=x++;
	}while (x !=2);

	std::cout<<a << b;
}
Topic archived. No new replies allowed.