I make tictactoe 2d array but my code run like this
1 || 2 || 3 4 || 5 || 6 7 || 8 || 9 Enter: 1 || || 4 || 5 || 6 7 || 8 || 9 There is my code: #include <iostream> #include <string> #include <stdio.h> using std::cout; void show(char pos[3][3]){ //system("cls"); int n = 1; for (int i=0; i < 3; i++) { for (int j = 0; j < 3; j++) { cout<<pos[i][j]; if(j < 2){ printf(" || "); } } printf("\n"); } } int main() { char pos[3][3], e; int n = 1; char player = 'O'; bool End = false; for (int i=0; i < 3; i++) { for (int j = 0; j < 3; j++) { pos[i][j] = '0' + n; n++; } } do { show(pos); scanf("%d", &e); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if(pos[i][j] == e){ pos[i][j] = player; if (player == 'X') player = 'O'; else player = 'X'; } While(true); } }