|
-
December 9th, 2008, 04:07 PM
#3
Re: Error I can't figure out in some simple C++ code, Please Help
Can you see any diference ? ....
Code:
int arrGameBrd[8][8];
int arrSolveBrd[8][8][8];
void ChangeOneValue();
void ChangeOneValue() {
// Declarations
int xCoor;
int yCoor;
char xyValue;
int intxyValue;
int count;
//BoardOut(0, 0); // I commented this to narrow down possible error location
cout << "Enter x coordinate(1-9) for the square to be changed." << endl;
cin >> xCoor;
if (xCoor < 1 || xCoor > 9) {
cout << "Invalid coordinate!" << endl;
return;
}
cout << "Enter y coordinate(1-9) for the square to be changed." << endl;
cin >> yCoor;
if (yCoor < 1 || yCoor > 9) {
cout << "Invalid coordinate!" << endl;
return;
}
//BoardOut(xCoor, yCoor); // I commented this to narrow down possible error location
cout << "Please enter the value for this square(1-9). Enter 0 to cancel." << endl;
cin.sync();
cin.get(xyValue);
cin.sync();
intxyValue = (xyValue - 48);
if (intxyValue < 0 || intxyValue > 9) {
cout << "Invalid value! Must be 1-9!" << endl;
return;
}
xCoor = (xCoor - 1);
yCoor = (yCoor - 1);
cout << xCoor << ", " << yCoor << endl; // added this line to find the problem, will refer to is as DBline0 below
cout << arrGameBrd[xCoor][yCoor] << ", " << arrGameBrd[1][0] << endl; // added this line to find the problem, will refer to it as DBline1 below
arrGameBrd[xCoor][yCoor] = intxyValue; // HERE'S THE PROBLEM LINE, see output below
cout << arrGameBrd[xCoor][yCoor] << ", " << arrGameBrd[1][0] << endl; // added this line to find the problem, will refer to it as DBline2 below
if (intxyValue != 0) {
for (count = 1; count < 10; count++) {
if (count == xyValue) {
}
else {
arrSolveBrd[xCoor][yCoor][(count - 1)] = 0;
}
}
}
return;
}
Please use code tags !!
Regards.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|