Printf-Tac-Toe

Printf-Tac-Toe: Devs cheer, gasp, and meme as one print call plays the game

TLDR: A coder made tic-tac-toe run from a single print call in C, turning a basic tool into a full game. The community is split between awe and alarm—praising the clever hack while debating whether this “printer that can compute anything” is genius, cursed, or a security cautionary tale.

Programmers are losing it over “Printf-Tac-Toe,” a wild entry from the IOCCC—the International Obfuscated C Code Contest—that plays tic-tac-toe using one single call to the print function. Yes, the thing that usually just prints text. The comments are split between “mad genius” and “burn it with fire.”

The big debate: how we got here. One user asked how a simple printer became “Turing-complete”—fancy talk for “can do any computation with enough time.” Others chimed in that this is both impressive and terrifying, since the trick uses a sneaky feature that lets printing also write to memory. Cue the security crowd reminding everyone that format strings can be a loaded weapon.

Meanwhile, the veterans are cackling. One commenter cracked a game-show joke about “My Dirty Programming Secrets,” then called printf “The One True Debugger,” and the old-guard is nodding along like it’s church. Newer devs are half-in awe, half-convinced this is dark magic. The code even ropes in a tiny input read so you can actually play—enter 1–9—and if you cheat, you lose. Brutal and funny.

Fans are linking to the academic bit behind this sorcery—Control-Flow Bending—while meme lords are printing “X” and “O” on T-shirts. It’s equal parts science fair, prank, and cautionary tale. And the crowd can’t look away.

Key Points

  • “Printf-Tac-Toe” is a C tic-tac-toe game implemented entirely within a single printf call, created for IOCCC 2020.
  • The program uses scanf for input and relies on advanced printf format features, notably %n/%hhn, positional parameters, and precision controls, to implement logic and state.
  • Usage: compile with gcc, run, and enter digits 1–9 to place moves; players alternate and the board is mapped to these digits.
  • Game termination conditions: win with three in a row, draw when the board is full, or loss by making an illegal move.
  • The article explains that printf can be Turing complete and references an academic paper (“Control-Flow Bending”) as context for this capability.

Hottest takes

"How did we end up with printf … being Turing-complete?" — danbruc
"Impressive and slightly terrifying" — idorozin
"I’ll take My Dirty Programming Secrets for 100, Alex" — JKCalhoun
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.