A simple console-based Tic-Tac-Toe game implemented in C. This project was created as part of a university assignment to demonstrate modular programming by separating functions into `.c` and `.h` files.
This project implements a two-player Tic-Tac-Toe game where players take turns to mark spaces in a 3x3 grid. The game checks for valid moves, detects winners, and declares a draw if all spaces are filled without a winner.
- Two-Player Mode: Play against a friend in turn-based gameplay.
- Console-Based: Lightweight game running directly in the terminal.
- Modular Design: Functions are organized in separate `.h` and `.c` files for better code structure.
- Error Handling: Ensures players input valid moves.
- Language: C
- Compiler: GCC (or any standard C compiler)
- Clone the repository:
git clone https://github.com/venujaranasinghe/Tic-Tac-Toe-Game.git cd Tic-Tac-Toe-Game
- Compile the program:
gcc main.c -o tictactoe
- Run the game:
./tictactoe
main.c
– Contains the main game loop and handles game flow.functions.h
– Includes all helper functions for game logic, such as move validation, board display, and win checks.
- Player 1 uses 'X' and Player 2 uses 'O'.
- Players take turns entering the position number (1-9) corresponding to the grid cell:
1 | 2 | 3 --------- 4 | 5 | 6 --------- 7 | 8 | 9
- The game declares a winner if a player aligns three of their marks horizontally, vertically, or diagonally.
- If all spaces are filled without a winner, the game declares a draw.
Feel free to fork the repository, make improvements, and submit a pull request.
Pending...
Developed by Venuja Ranasinghe.
GitHub: venujaranasinghe