Create a new C++ console application using Microsoft Visual Studio 2019. Add a file, name it tictactoe.c. Paste the code given below -
#include <stdio.h>
int main(void)
{
int player = 0;
int winner = 0;
char board[3][3] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'} };
//The main game loop. The game continues for up to 9 turns.
for (unsigned i = 0; i < 9 && winner == 0; ++i) {
//Display the board
printf("\n");
printf(" %c | %c | %c \n", board[0][0], board[0][1], board[0][2]);
printf("-----+-----+-----\n");
printf(" %c | %c | %c\n", board[1][0], board[1][1], board[1][2]);
printf("-----+-----+-----\n");
printf(" %c | %c | %c\n", board[2][0], board[2][1], board[2][2]);
player = i % 2 + 1;
}
return 0;
}
Build it, and then run it.
For some reason, Windows defender thinks it has detected a threat!!!



