Project
Project
h>
#include <stdbool.h>
// Function prototypes
void initialize_board(char board[3][3]);
void print_board(char board[3][3]);
bool is_valid_move(char board[3][3], int row, int col);
bool check_winner(char board[3][3], char symbol);
bool is_board_full(char board[3][3]);
int main() {
char board[3][3];
char player1 = 'X';
char player2 = 'O';
int row, col;
bool player1_turn = true;
bool game_over = false;
// Game loop
while (!game_over) {
// Print the board
print_board(board);
// Switch players
player1_turn = !player1_turn;
} else {
printf("Invalid move. Try again.\n");
}
}
return 0;
}
fi
// Initialize the board with empty spaces
void initialize_board(char board[3][3]) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
board[i][j] = ' ';
}
}
}