Skip to content

venujaranasinghe/Tic-Tac-Toe-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Tic-Tac-Toe Game 🎮

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.


Description 📝

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.


Features ✨

  • 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.

Technologies Used 💻

  • Language: C
  • Compiler: GCC (or any standard C compiler)

Setup Instructions ⚙️

  1. Clone the repository:
    git clone https://github.com/venujaranasinghe/Tic-Tac-Toe-Game.git  
    cd Tic-Tac-Toe-Game
  2. Compile the program:
    gcc main.c -o tictactoe
  3. Run the game:
    ./tictactoe

Folder Structure 📂

  • 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.

How to Play 🎲

  1. Player 1 uses 'X' and Player 2 uses 'O'.
  2. Players take turns entering the position number (1-9) corresponding to the grid cell:
  1 | 2 | 3
  ---------
  4 | 5 | 6
  ---------
  7 | 8 | 9
  1. The game declares a winner if a player aligns three of their marks horizontally, vertically, or diagonally.
  2. If all spaces are filled without a winner, the game declares a draw.

Contribution 🤝

Feel free to fork the repository, make improvements, and submit a pull request.


License 📝

Pending...


Contact

Developed by Venuja Ranasinghe.

GitHub: venujaranasinghe

About

Created for a assignment in university.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages