can someone please help i have been programming tic-tac toe for 2 hours and i can't find the error it unexpectedly terminates itself after the first two turns
(i have substituted x & o for 3 & 5)
Using 0 instead of 1 as start-value would solve the problem.
Besides that, you should consider using some for-loops. That would make the code a lot shorter. And i dont see the goto statement often. Using a while or a do loop would make the code clearer.
Its perfectly doable to use x and o instead of 3 and 5:
for (int i=0;i<=2;i++)
{
for (int j=0;j<=2;j++)
{
if (cor[i][j]==3) cout<<"x";
if (cor[i][j]==15) cout<<"o";
if (cor[i][j]==0) cout<<"_";
cout<<"|";
}
cout<<"\n"<<j+1;
}
And i would use a char or string type variable to store the input from the user in after the 'play again' question: if he now types a letter the program will chrash
(I havent tested those codes, there may be some mistakes in it)
I played this game, and its looks good, this is in fact is my In Course Assessment for C++ at University of Teesside, but the only difference is they want 7 by 6 grid :(...
Although the program runs good, but i found something that could be improved on...
What if player 1 enters the co-ords of [ 1 1] and player 2 enters the same, i tried this and found that the player switched over, maybe there should be an error telling player 2 that he entered the wrong co-ords and should re enter it again.
Also when i enter the 1st co-ords such as [3 2] it doesn't place where i wanted it, instead it placed it in 2 along the rows and 3 down... :/