TRT
Sign in

Foundations · Module 1

Writing, Building and Running Your First Programs

Compile, run and debug a small C++ program while understanding what the toolchain and the machine do at each step.

Start the moduleFree9 lessons · about 82 minutes

Every later idea in C++ rests on three foundations: how text becomes a running program, how values are stored in memory, and how to read what your tools tell you. This module builds all three with small programs that you compile, run and step through yourself. By the end you can build a program from the command line, predict how its values are stored, and diagnose the first errors you meet.

  1. 1From Source Text to a Running ProgramFollow a five-line program through the preprocessor, compiler and linker, and learn which stage produces which file and which kind of error.9 min
  2. 2Anatomy of Your First ProgramRead a six-line program token by token: who calls main, what std:: and the insertion operator really mean, how a chain of insertions works, and where the returned number goes.9 min
  3. 3Variables Are Names for BytesSee a variable as what it really is: a named, typed region of bytes. Trace four lines of code through eight bytes of memory, including how numbers are laid out and what copying does.10 min
  4. 4Types Decide What Bits MeanLearn why the same bytes can be -1 or 4294967295: how types fix size and meaning, how two's complement and floating point store numbers, and how conversions and wraparound behave.7 min
  5. 5Reading Input and Surviving Bad InputRead values with std::cin, see what a failed read does to the variable and to the stream, and build the clear-and-discard loop that survives bad input.9 min
  6. 6Reading Compiler Errors and WarningsLearn the structure of a compiler diagnostic, why one typo can print several errors, which message to fix first, and which warning flags catch the mistakes from earlier lessons.8 min
  7. 7Stepping Through a Program With a DebuggerBuild a program for debugging, pause it at a breakpoint, step through it line by line and inspect variables, and learn how a debugger stops a running program without changing your source.8 min
  8. 8Build Systems and Toolchains: CMake BasicsTurn a multi-file C++ program into a repeatable build with CMake, explicit language versions and separate debug and release configurations.11 min
  9. 9Initialization, const and ConversionsChoose initialization deliberately, preserve invariants with const, and make narrowing conversions visible instead of accidental.11 min