The Threshold
The Atari 2600 has 128 bytes of RAM. That number is not a development philosophy — it is a physical constraint. A C program needs a stack for function calls, space for local variables, a mechanism for returning from functions. There is no room.
The 2600 ran assembly because nothing else fit. The NES had 2 kilobytes. The SNES had 128 kilobytes. Better each time, but still machines where a C compiler's overhead was visible — where the code it generated was measurably slower and larger than what a skilled programmer could write by hand. The developers who made those games wrote assembly because the hardware demanded it.
The PlayStation[1][2] ran a MIPS R3000A[3] — a 32-bit RISC processor built with compilers in mind.

A clean register file, no legacy quirks, predictable pipeline behaviour. It had 2 megabytes of RAM. Its software came on CD-ROM rather than cartridge, removing the code-size constraint entirely. For the first time, a mass-market console had hardware that a C compiler could target efficiently. Sony recognised this; SN Systems[4] built the Psy-Q SDK that most PlayStation studios used.
The N64 and Game Boy Advance followed with C-based SDKs. C became the language consoles ran on — not by choice over assembly, but because the hardware had finally caught up.
This is where it starts. The language is C. The first program is twenty lines.
The implementation pages build up from the compilation pipeline to a working guessing game, one concept at a time: types and values, control flow, functions, the standard library. The final page brings everything together and points you at the Doom source code — the same C you just learned to write, at a different scale. Start at Setup.
Every Program Starts Here
The first C program I wrote compiled on the third try. The first two attempts produced error messages I did not understand — something about an implicit declaration, something about a missing semicolon the compiler said was on a line that looked fine to me. I stared at it for ten minutes before noticing the missing semicolon was on the line above the one the compiler pointed at. That is a lesson you learn once and never forget: the compiler tells you where it gave up, not always where the mistake is.
When it finally ran and printed Hello, world. I felt approximately
nothing, which surprised me. It was twenty lines and one function call.
But looking back, that moment contained everything: a source file,
a preprocessor pulling in a header, a compiler turning text into object
code, a linker producing an executable, the operating system loading it.
The pipeline from .c to running program is the same pipeline that
built Crash Bandicoot, just at a different scale. The concepts do not
change when the programs get larger.
C has five things you need before you can write anything useful: types and variables to hold values, arithmetic to transform them, control flow to make decisions and repeat, functions to organise the work, and the standard library to talk to the outside world. This chapter covers all five through four programs: hello world, a calculator, a word counter, and a guessing game. Each one introduces the next concept. By the guessing game, you have used everything.
The programs are small. The calculator is not a production calculator. The word counter counts words in a single line. The guessing game has no graphics. None of that matters yet. What matters is understanding the pipeline, reading compiler errors without panic, and seeing how the pieces connect. The scale comes later.
The Project
- Write
hello.c: a program that prints a greeting and exits cleanly. - Write
calculator.c: reads two numbers and an operator from standard input, performs the operation, and prints the result. Supports+,-,*,/. Handles division by zero. - Write
words.c: reads one line from standard input and prints the number of words and the number of characters it contains. - Write
guess.c: picks a random number between 1 and 100, reads guesses from the user, and responds with "Too high.", "Too low.", or the number of attempts it took to guess correctly.
All four programs must compile cleanly with gcc -Wall -Wextra.
The Tester
The tester lives in thecodingidiot-com/f04-writing-c. Copy
test.sh into your working directory and run it from there:
cp test.sh ~/f04-practice/
cd ~/f04-practice
bash test.shIt verifies:
hello.ccompiles and its output contains a greeting.calculator.ccompiles and produces correct results for a set of test inputs.words.ccompiles and counts words correctly for a set of test inputs.guess.ccompiles cleanly. The game is interactive — the tester cannot play it. That check is self-certified.