C
The small, fast language underneath operating systems, firmware and language runtimes: how C programs are built, how they use memory directly through pointers, why that makes them powerful and risky, and how compilers, sanitizers and debuggers help you write safer C.
18 pages 127 glossary terms
How to use this topic
The first six pages cover the basics: what C is, compiling and running a program, types and integers, operators and conversions, control flow, and functions with header files. Pages 7 to 13 are about working with memory: pointers, arrays, strings and buffer overflows, structs, dynamic memory, files and error handling. The last five cover the craft around the language: the preprocessor and make, undefined behavior and safer C, debugging, the standard library and portability, and what modern C adds.
General ideas such as pointers, the stack and the heap are introduced in Programming Concepts: memory management; this topic goes deeper and stays C-specific. If you work with microcontrollers, the firmware page in IoT & Embedded Systems shows where C fits on small devices. Exit status, signals and core dumps are explained in Linux & Command Line, and how the vulnerabilities that memory bugs cause are tracked and fixed in vulnerability management.
Every runnable C example is a complete program compiled with GCC (C23 examples with Clang) with all common warnings turned into errors, and shows its exact output; output from sanitizers, the debugger and make was recorded on a 64-bit Linux machine (ARM64).
Pages are tagged with the certifications they help with: CLA (C Certified Associate Programmer) on the core language pages, and CLP (C Certified Professional Programmer) on the pages about the history of C, strings, error handling, undefined behavior and the standard library; both exams are from the C++ Institute. Debugging and modern C go beyond those exams and are untagged.
Learning path
- 01What Is C?What C is and why it is still everywhere: its origin at Bell Labs next to Unix, the ISO standards from C89 to C23, where C runs today and what it leaves to the programmer.
- 02Compiling and Running CFrom source file to running program: the preprocessor, compiler, assembler and linker, GCC and Clang, warning flags that catch bugs early, optimization levels and exit status.
- 03Variables, Types and IntegersC's basic types and their sizes on a 64-bit machine, fixed-width integers from stdint.h, signed versus unsigned, overflow and wraparound, the signedness of char, and floating-point traps with money.
- 04Operators, Expressions and ConversionsArithmetic, comparison, logical and bitwise operators, integer division and remainder, precedence, and the implicit conversions — integer promotion and the usual arithmetic conversions — that surprise newcomers.
- 05Control Flow and Loopsif and else, switch and its fall-through, for, while and do-while loops, break, continue and goto, and the classic mistakes the compiler can warn about.
- 06Functions and Header FilesDeclaring and defining functions, prototypes and pass by value, splitting a program into .c and .h files with include guards, and how static and extern control linkage and lifetime.
- 07PointersWhat a pointer holds, taking addresses and dereferencing, null and dangling pointers, void pointers, const with pointers, pointers to pointers and function pointers.
- 08Arrays and Pointer ArithmeticFixed-size arrays and their initialization, how arrays decay to pointers, pointer arithmetic, the array length idiom, multidimensional and variable-length arrays, and why C never checks bounds.
- 09Strings and Buffer OverflowsStrings as null-terminated character arrays, the string.h functions and their traps, safe copying and formatting with snprintf, parsing numbers with strtol, and how buffer overflows happen and are prevented.
- 10Structs, Unions and EnumsGrouping data in structs, designated initializers, the arrow operator, padding and alignment, bit-fields, unions that share memory, enums and typedef.
- 11Dynamic MemoryAllocating memory at run time with malloc, calloc and realloc, releasing it with free, who owns what, and the classic heap bugs: leaks, use-after-free, double free and heap overflows.
- 12Input, Output and Filesprintf and its conversion specifications, reading input safely with fgets and sscanf, opening, reading and writing files with stdio, buffering, and the three standard streams.
- 13Error HandlingHow C reports errors without exceptions: return values, NULL and EOF, errno with perror and strerror, exit status, the goto cleanup pattern and assert.
- 14The Preprocessor and Build Tools#include, #define and conditional compilation, macros and their pitfalls, include guards, and building multi-file programs with make and CMake.
- 15Undefined Behavior and Safer CWhat undefined, unspecified and implementation-defined behavior mean, how optimizers exploit undefined behavior, memory safety and the push toward memory-safe languages, and the tools and coding standards that make C safer.
- 16Debugging CFinding bugs in C programs: reading crashes and exit codes, stepping through code with GDB, breakpoints and watchpoints, and catching memory errors with AddressSanitizer and UndefinedBehaviorSanitizer.
- 17The Standard Library and PortabilityA tour of the C standard library — sorting, searching, math and time — the C libraries that implement it, POSIX versus ISO C, and the traps that make C code behave differently on another machine.
- 18Modern C and Where C Is UsedWhat C23 added — nullptr, constexpr, typeof, #embed, attributes and checked arithmetic — what is coming in C2y, compiler support today, and where C is used in kernels, firmware, runtimes and libraries.
C glossary
Short definitions of the terms used in this topic. The full glossary covers every topic.