Skip to content
Projetos

dunamismax/c-from-the-ground-up

Ver no GitHub

Sobre

A free, progressive course in C: 38 small, runnable programs that take you from your first printf to pointers, memory, sockets, threads and a terminal game you build yourself.

Aprendizado e educação

Como estes números são medidos

Crescimento medido de estrelas

em 24 h
+1
em 7 dias
+3
em 15 dias
Coletando histórico
em 1 mês
Coletando histórico

Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.

README.md

Original

C From The Ground Up

A free, progressive course in C: 38 small, runnable programs that take you from your first printf to pointers, memory, sockets, threads and a terminal game you build yourself.

Start learning at cfromthegroundup.com →

Start lesson 1 · Browse all 38 lessons · Set up a compiler

Free · Open source · No sign-up · No ads or third-party trackers

Analytics, when it is switched on, is the site's own copy of Umami: it counts page views, sets no cookies and stores no IP addresses. The privacy policy lists exactly what the site records.


The cfromthegroundup.com home page: Learn C from the ground up, with Start lesson 1 and Browse the course buttons next to a terminal running Hello, World!

The course website

cfromthegroundup.com is the best way to take this course. It is built from the files in this repository, so it always shows exactly the code that compiles here, and it adds everything you want while learning:

  • Lessons made for reading. Each lesson is a page: the explanation first, then the full program with line numbers and syntax highlighting, where the comments are the lesson.
  • Track your progress. Mark lessons complete, see how far you are through each part, and pick up where you left off. Your progress is saved in your browser, with no account needed.
  • Run code without installing anything. "Try it online" opens most lessons in Compiler Explorer with the right flags, ready to run.
  • Compile it yourself, on any system. Every lesson has copy-ready compile and run commands for macOS, Linux and Windows (WSL), and the setup guide walks you through installing a compiler.
  • Find anything. Search every lesson, heading and code comment. Press / anywhere on the site.
  • Take it with you. Download any file, any lesson as a zip, or the whole course.
  • Built for everyone. Light and dark themes, full keyboard navigation (j and k move between lessons), automated WCAG 2.2 AA accessibility checks, and fast pages: Lighthouse scores of 99 to 100.
Lesson 20, Linked Lists, on the site: the course sidebar, the lesson text and an on-this-page outline.

Every lesson explained in plain language

The full source of lesson 20 on the site, with line numbers and Copy, Download and View on GitHub buttons.

The full program, with the comments as the lesson

What you will learn

Six parts, taken in order. Each lesson only uses ideas that earlier lessons taught.

Part Lessons What it covers
1. The Beginner Path 1-9 Hello World, variables, input, operators, conditions, loops, functions, arrays and strings
2. The Intermediate Path 10-15 Pointers, structs, dynamic memory, file I/O and command-line arguments
3. The Advanced Path 16-25 Function pointers, recursion, linked lists, bit manipulation, the preprocessor and a line-based text editor
4. The Expert Path 26-30 Sockets, your own grep, hash tables, a tiny shell and multithreading
5. Expert Systems 31-35 Multi-file projects, external libraries, ncurses terminal UIs, data parsing and a capstone text adventure
6. The Toolsmith Path 36-38 Debugging with gdb and lldb, undefined behavior and the sanitizers, and testing in C

Start with lesson 1: Hello, World! →

Other ways to read it

  • The book edition: the same lessons as an mdBook on GitHub Pages. It is kept as a mirror, and every page links to its lesson on the site.
  • This repository: the source of the course. Every lesson is one .c file under Part */, and the site and the book are both generated from those files. Clone it to read and run the lessons in your own editor. Worked solutions to the Part 1 and Part 2 exercises (lessons 1-15) are in exercises/.

Running the lessons from this repository

Most lessons are single-file programs. Pick one .c file, compile it, and run it:

cc -Wall -Wextra -std=c17 \
  "Part 1 - The Beginner Path_ Core Concepts/1_hello_world.c" \
  -o /tmp/1_hello_world

/tmp/1_hello_world

The site's setup guide covers installing a compiler on macOS, Linux and Windows. On Windows the course runs inside WSL (the Windows Subsystem for Linux), which is the supported way to take it there.

Lesson 31 is the exception: it is intentionally split across multiple files and built with its local Makefile.

make -C "Part 5 - Expert Systems & Application Development/31_make_files_for_multi_file_projects"

Build notes

  • The lessons teach C17 (-std=c17), which every current compiler accepts. CI compiles every lesson with -std=c17 and again with -std=c23, so the course also builds on the newest standard.
  • Most lessons compile with cc -Wall -Wextra -Wpedantic -Wstrict-prototypes -std=c17 lesson.c -o lesson_name.
  • CI also turns on -Wshadow -Wconversion -Wsign-conversion -Wmissing-prototypes and treats every warning as an error, under both GCC and Clang.
  • Lessons 26 through 30 use POSIX or Unix-style APIs such as sockets, fork, waitpid, unistd.h, and pthread.
  • Lesson 30 needs -pthread.
  • Lesson 32 needs -lm.
  • Lessons 33 and 35 need -lncurses or -lncursesw, depending on your system, so they need macOS, Linux, or WSL on Windows.
  • Several lessons expect runtime input or data files. Read the lesson comments before running them.

Working on the project

The website lives in site/ (SvelteKit, Svelte 5, TypeScript, Tailwind CSS, PostgreSQL) and reads the lessons and chapters at build time; site/README.md has the developer quick start. The book is built with mdBook:

mdbook build
mdbook serve --open

One command runs the full local gate, the same checks CI runs:

make verify

It checks that the book's listings match the .c files and that the lessons are formatted, runs clang-tidy over them, builds the book and checks its links, compiles every lesson with warnings as errors under Clang and GCC (and runs behavioural checks on the interactive ones), runs the lessons under AddressSanitizer, UndefinedBehaviorSanitizer and LeakSanitizer, fuzzes the two file parsers (lessons 34 and 35) where Clang has libFuzzer, and type-checks, lints, tests and builds the website. If your local GCC is versioned, point at it with make verify GCC=gcc-15; on macOS, plain gcc is usually Clang under another name. The website's end-to-end tests run with make site-e2e.

You need a C compiler, make, Python 3, mdBook 0.5.4, clang-format and clang-tidy 23, the ncurses headers, and Node 26.13.1 with pnpm 12.18.0. AGENTS.md lists the exact versions and how to install them.

The .c files are the single source of truth for code. Each chapter in src/chapters/ embeds its lesson's source through a <!-- source: ... --> marker, and make sync copies the current file contents into the book. Edit the .c file, run make sync, then make verify.

  • CONTRIBUTING.md -- how to report a mistake, send a correction and run the checks; start here
  • SECURITY.md -- how to report a security problem with the site privately
  • AGENTS.md -- repository layout and conventions in full, and the maintainer's own workflow (written for AI agents, useful for humans too)
  • BUILD.md -- how the course and the site were built, the decisions behind them, and what was left unbuilt
  • CHANGELOG.md -- the releases

Found a mistake, or a comment that confused you? A wrong comment is a bug: please open an issue. CONTRIBUTING.md says what to include, and when a pull request is welcome.

Project status

Complete. v2.0.0 is the final release: all 38 lessons, the website and the book are finished, and no new lessons are planned. The repository stays open, and corrections are still welcome.

License

This project is licensed under the MIT License. See LICENSE.

Explore projetos relacionados

Carregando…