Couple questions for my Tic Tac Toe game C++
Hey guys I have a couple questions I'm having trouble with.. First is I can't get out of my For loop for my game.. I want the game to end when the board is full and I will cout "tie" or something more exciting but even when I have it set to (j=0; j<9ji++) it is not exiting. Also with my array I can't figure out how to get bars across my rows (for looks purposes) I can do the columns but can not figure out the rows. I would like to keep it as much to the same format as possible. int i, j; int nums[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1 }; cout << "Welcome to Tic Tac Toe!" << endl; display(nums); for (j = 0; j < 9; j++) { //enter x do { cout << "Please enter an X in an unplayed position." << endl; cin >> i; //1-9 if (nums[i - 1] != -1) cout << "Invalid Space! Space already taken." << endl; else break; } while (true); nums[i - 1] = 1; display(nums); //display if (gameoverx(nums)) //check to see if game is over break; cout << "The computer's move is..." << endl; system("pause"); ai(nums); //enter O display(nums); if (gameovero(nums)) //check to see if game is over break; } cout << "Thank You for playing!!!" << endl; system("pause"); } void display(int n[]) { int count = 0; int r, c; for (r = 0; r < 3; r++) { for (c = 0; c < 3; c++) { if (n[count] == -1) cout << setw(2) << count + 1 << " |"; else if (n[count] == 1) cout << setw(2) << 'X'; else if (n[count] == 0) cout << setw(2) << 'O'; count++; } cout << endl; } }