Condition

I'm writing a TicTacToe exercise, And i've narrowed it down to a condition that alway's read's false. I think the problem is in line 66.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104`` ``````#include #include int Carr[9] = {3,3,3,3,3,3,3,3,3}; int ArrPos = 0; int MoveNotLegal =1; char LetInp; char &LetRef = LetInp; int LetConvRef = LetRef; int Xcoord = 0; int Ycoord = 0; int RedrawBoard() // 1 = Plyr 1; 2 = Plyr 2; 3 = Blank { int Column = 1; std::cout << std::endl; std::cout << " A B C\n\n" << Column; int LineCount = 1; for (int y = 0; y <= 8; ++y, ++LineCount) { if (Carr[y] == 1) { std::cout << " X"; } if (Carr[y] == 2) { std::cout << " O"; } if (Carr[y] == 3) { std::cout << " *"; } if (LineCount == 3 && Column != 3) { LineCount = 0; std::cout << '\n'; ++Column; std::cout << Column; } } return 0; }; void resetBoard() { for (int i = 0; i <= 8; ++i) Carr[i] = 3; }; int GetPlayerMove(int Plyr) { MoveNotLegal = 1; do { char LetInp; int Ycoord = 0; std::cout << "\nPlayer " << Plyr << " Enter column from (A - C): "; std::cin >> LetInp; std::cout << "\nPlayer " << Plyr << " Enter row from (1-3): "; std::cin >> Ycoord; --Ycoord; Xcoord = LetConvRef - 97; ArrPos = (3 * Xcoord) + Ycoord; if (Carr[ArrPos] == 3) { Carr[ArrPos] = Plyr; MoveNotLegal = 0; } } while (MoveNotLegal != 1); MoveNotLegal = 1; return 0; } int main() { int Player =1; int GameLive = 1; char PlayAgain = 'y'; RedrawBoard(); do { GetPlayerMove(Player); ++Player; RedrawBoard(); // Check for win if (GameLive == 1) { GetPlayerMove(Player); --Player; RedrawBoard(); // Check for win } if (GameLive == 0) { std::cout << "\nWould you like to play again? (y or n) "; std::cin >> PlayAgain; } } while (PlayAgain == 'y' || PlayAgain == 'Y'); }``````
Last edited on
What is line 66 trying to say? It looks to me like you meant to say `if(ArrPos == 3)`
Thank's a bunch booradley60. I was writing several part's of the program at once, Got lost in my own logic :)
Topic archived. No new replies allowed.