Tic-Tac-Toe

Build a two-player Tic-Tac-Toe game from scratch in modern C++ using only the standard library. You represent the board as a small grid, alternate turns between players, validate moves, and check every win line after each play. A satisfying project for practising arrays, functions, and game logic.

~1.8 hours
1 steps

Support Free C++ Education

Help us keep this platform free for everyone! Your support enables us to create more high-quality lessons, exercises, and interactive content.

Become a Patron

What You'll Build

A console Tic-Tac-Toe game for two players that draws a 3x3 board, accepts numbered moves, rejects illegal placements, and detects wins, blocks, and draws.

Learning Objectives

  • Represent a 3x3 grid with a std::array or fixed-size array
  • Render the board to std::cout with clear row and column separators
  • Validate that a chosen cell is on the board and still empty
  • Alternate turns between two players with a tracked current-player value
  • Check rows, columns, and diagonals for a winning line
  • Detect a full-board draw and end the game cleanly

Ready to Start?

Start Project

Sign in to retain your progress

Project Steps

Step 1

Tic-Tac-Toe

Write the whole game: draw a numbered 3x3 board, alternate moves between X and O, reject illegal cells, check every win line, detect a draw, and offer another game.

~110 min

Ready to Start?

Start Project

Sign in to retain your progress