Glossary
The key terms the lessons introduce, in the UPPERCASE the lesson comments use when a term first appears. Each entry links to the lesson that teaches it.
A
- Address: The number that identifies a location in memory. Every variable lives at an address, which
&gives you and%pprints. (Lesson 10) - Address-of operator (
&): Gives the memory address of a variable, as in&user_age.scanfneeds it so it knows where to store what it reads. (Lesson 3) - AddressSanitizer (ASan): A sanitizer, turned on with
-fsanitize=address, that stops a program at its first out-of-bounds access, use afterfreeor similar memory error and reports where it happened. (Lesson 36) argcandargv: The two parameters ofmainthat receive command-line arguments: the argument count, and an array of the arguments as strings.argv[0]is the program's name. (Lesson 15)- Argument: A value passed to a function when it is called. In
calculate_damage(20, 8), 20 and 8 are the arguments. (Lesson 7) - Array: A fixed-size, numbered sequence of elements of the same type, stored next to each other in memory. (Lesson 8)
- Arrow operator (
->): Reaches a struct member through a pointer:p->gpameans(*p).gpa. (Lesson 12) - Assertion (
assert): A check from<assert.h>that stops the program if a condition that must be true is false. Compiling with-DNDEBUGremoves it. (Lesson 38) - Atomic operation: An operation that happens as one indivisible step, so no other thread can see it half done.
count++is not atomic. (Lesson 30)
B
- Backtrace: The chain of function calls that led to the current line, innermost first. Also called the call stack. (Lesson 36)
- Base case: The condition that stops a recursive function from calling itself again. Without one, recursion never ends. (Lesson 19)
- Binary library file: The compiled code of a library (
.soon Linux,.dylibon macOS) that the linker connects to your program. (Lesson 32) - Bit: A single binary digit, 0 or 1. A byte is 8 bits. (Lesson 21)
- Bitmask: A value whose bits select other bits, used with
&,|and^to set, clear, test or toggle flags. (Lesson 21) - Bitwise operators: Operators that work on the individual bits of integers:
&,|,^,~,<<and>>. (Lesson 21) - Blocking call: A function that waits until something happens, such as
accept()waiting for a client to connect. (Lesson 26) - Breakpoint: A place where a debugger pauses the program, such as the start of a function. (Lesson 36)
- Buffer: A block of memory that holds data on its way somewhere, such as a
chararray thatfgetsreads a line into. (Lesson 6) - Buffer overflow: Writing past the end of a buffer. It corrupts other memory and is a classic source of crashes and security holes. (Lesson 9)
C
- Callback: A function passed (as a function pointer) to another function, which calls it to do part of its work. (Lesson 18)
- Cast: An explicit conversion to another type, written
(type)value, as in(double)a / b. (Lesson 13) - Character literal: A single character in single quotes, such as
'A'. Its type isint, and it fits in achar. (Lesson 2) - Child process: The new process that
fork()creates. It starts as a copy of its parent. (Lesson 29) - Client-server model: A design where a server waits for requests and clients connect to it to make them. (Lesson 26)
- Collision: Two different keys hashing to the same bucket of a hash table. (Lesson 28)
- Compiler: The program that translates C source code into machine code your computer can run. In this course it is
cc: GCC or Clang. (Lesson 1) - Conditional compilation: Using
#if,#ifdefand#ifndefto include or leave out code before compiling, for example debug output. (Lesson 22) - Conditional statement: Code that runs only when a condition is true:
if,else if,elseandswitch. (Lesson 5) - Critical section: Code that touches shared data and must be run by only one thread at a time, usually guarded by a mutex. (Lesson 30)
D
- Dangling pointer: A pointer to memory that has been freed. Using it is undefined behavior, which is why lessons set pointers to
NULLafterfree. (Lesson 13) - Data type: What kind of value a variable holds, and so how much memory it needs and what you can do with it:
int,double,charand so on. (Lesson 2) - Debug information: The map from machine code back to source files, lines and variable names that
-gadds, so a debugger and sanitizers can name them. (Lesson 36) - Debugger: A program, such as gdb or lldb, that runs your program under its control so you can pause it, step through it and inspect its variables. (Lesson 36)
- Declaration: Introducing a name and its type to the compiler, as in
int player_score;. A function declaration is its prototype. (Lesson 2) - Definition: The part that actually creates something: a function with its body, or a variable with its storage. (Lesson 7)
- Dereference: Following a pointer to the value it points to, with
*:*p_scoreis theintthatp_scorepoints at. (Lesson 10) - Doubly linked list: A linked list whose nodes point both to the next node and to the previous one. (Lesson 25)
- Dynamic memory allocation: Requesting memory while the program runs, with
malloc(andrealloc), and giving it back withfree. (Lesson 13)
E
- Edge case: An input at the boundary of what code handles, such as an empty string or a value exactly at a limit. Bugs hide there, so tests should cover them. (Lesson 38)
- Enum: A type made of named integer constants, such as
SUCCESSandFAILURE, so code uses names instead of magic numbers. (Lesson 23) - EOF: "End of file": the special negative value input functions return when there is no more input. Ctrl+D sends it from a terminal. (Lesson 3)
- Escape sequence: A backslash code inside a string or character literal for a character you cannot type directly, such as
\n(newline). (Lesson 1) - Exit status: The number
mainreturns to the operating system: 0 for success, anything else for failure. Scripts and CI read it. (Lesson 38) extern: Declares a global variable that is defined in another source file, so this file can use it. (Lesson 24)
F
- File descriptor: A small integer the operating system uses to identify an open file or socket. (Lesson 26)
FILEpointer: TheFILE *thatfopenreturns and every stdio file function takes. Always check it forNULL. (Lesson 14)- Floating-point: Numbers with a fractional part, stored as
floatordouble. This course prefersdouble. (Lesson 2) fork(): The POSIX system call that creates a new process. It returns 0 in the child and the child's ID in the parent. (Lesson 29)- Format specifier: A placeholder such as
%d,%f,%cor%sthat tellsprintforscanfwhat type of value goes there. (Lesson 2) - Function: A named block of code that does one task, can take parameters and can return a value. (Lesson 7)
- Function pointer: A variable that holds the address of a function, so the function to call can be chosen at run time. (Lesson 18)
H
- Hash function: A function that turns a key into an array index for a hash table. (Lesson 28)
- Hash table: A data structure that maps keys to values, using a hash function to find each key's bucket quickly. (Lesson 28)
- Header file: A
.hfile of declarations (function prototypes, types, macros) that other files#include. (Lesson 31) - Header guard: The
#ifndef NAME/#define NAME/#endifwrapper that stops a header from being included twice. Also called an include guard. (Lesson 22) - Heap: The pool of memory that
mallochands out. Memory there lives until youfreeit. (Lesson 13)
I
- Index: The position of an element in an array. C counts from 0. (Lesson 8)
- Infinite loop: A loop whose condition never becomes false, so it never ends. (Lesson 6)
- Initialization: Giving a variable its first value, ideally when you declare it:
int number_of_lives = 3;. (Lesson 2) - Input buffer: Where typed input waits until a program reads it. Characters
scanfdoes not use, such as a newline, stay there for the next read. (Lesson 3) - Integer division: Dividing two integers in C, which throws away the fractional part:
10 / 3is 3. (Lesson 4) - Integer promotion: C widening small types such as
charoruint8_ttointbefore doing arithmetic or bitwise operations on them. (Lesson 21) - Iteration: One run through the body of a loop. (Lesson 6)
L
- Linkage: Whether a name can be seen from other source files.
staticat file scope gives internal linkage: private to its file. (Lesson 24) - Linked list: A chain of nodes, each holding data and a pointer to the next node. It can grow and shrink one node at a time. (Lesson 20)
- Linker: The tool that joins object files and libraries into one program, connecting each function call to its definition. (Lesson 31)
- Logical operators:
&&(and),||(or) and!(not), which combine or invert true/false values. (Lesson 4)
M
- Macro: A name that the preprocessor replaces with text before compiling, made with
#define. (Lesson 22) - Main function:
main, where every C program starts running. Its return value is the program's exit code. (Lesson 1) - Makefile: The file
makereads: rules saying how to build each target from its dependencies. (Lesson 31) - Member: One of the named fields inside a struct, reached with
.or->. (Lesson 12) - Memory leak: Memory that was allocated and never freed. A long-running program that leaks keeps growing. (Lesson 13)
- Modulus (
%): The remainder of an integer division:10 % 3is 1. (Lesson 4) - Mutex: A lock that only one thread can hold at a time, used to protect shared data from race conditions. (Lesson 30)
N
- ncurses: A library for full-screen terminal programs: cursor movement, colors, windows and single-key input. (Lesson 33)
- Network byte order: The byte order (big-endian) that network protocols use.
htonsconverts a port number to it. (Lesson 26) - Node: One element of a linked list or tree: some data plus one or more pointers to other nodes. (Lesson 20)
NULL: A pointer value that points nowhere. Functions such asmallocandfopenreturn it to report failure. (Lesson 10)- Null terminator: The
'\0'character that marks the end of a C string. (Lesson 9)
O
- Off-by-one error: A loop or index that goes one step too far or stops one step short, such as using
<=where<was needed. (Lesson 36) - Operator precedence: The rules for which operator is applied first, as in math:
5 + 2 * 10is 25. Parentheses override them. (Lesson 4)
P
- Parameter: A variable in a function's definition that receives the value of an argument. (Lesson 7)
- Parent process: The process that called
fork(). It usually waits for its child withwaitpid(). (Lesson 29) - Parsing: Turning text, such as a line of a data file, into structured values like the members of a struct. (Lesson 34)
- Pointer: A variable that holds a memory address.
int *pis a pointer to anint. (Lesson 10) - Pointer arithmetic: Adding to or subtracting from a pointer to move between array elements:
p + 1points at the next element. (Lesson 11) - Port: A number that, with an IP address, identifies one program's network endpoint on a machine. (Lesson 26)
- POSIX: The standard for Unix-like operating systems (Linux, macOS) that defines APIs such as
fork, sockets and pthreads. Lessons 26-30 use it. (Lesson 30) - Preprocessor: The first stage of compiling, which handles lines starting with
#: includes, macros and conditional compilation. (Lesson 22) - Preprocessor directive: A line starting with
#, such as#include <stdio.h>, handled by the preprocessor before compiling. (Lesson 1) - Process: A running program, with its own memory.
fork()creates a new one. (Lesson 29) - Prototype: A function's declaration: its return type, name and parameter types, ending in a semicolon. It lets you call a function defined later. (Lesson 7)
R
- Race condition: A bug where the result depends on how threads happen to interleave, such as two threads both updating a counter and one update being lost. (Lesson 30)
realloc: Resizes a block frommalloc, copying its contents if it has to move. On failure it returnsNULLand leaves the old block alone. (Lesson 25)- Recursion: A function calling itself on a smaller version of its problem until it reaches a base case. (Lesson 19)
- Relational operators:
==,!=,<,>,<=and>=, which compare two values and give 1 (true) or 0 (false). (Lesson 4) - Return value: The value a function sends back to its caller with
return. (Lesson 7)
S
- Sanitizer: A checker the compiler builds into a program (
-fsanitize=...) that reports certain bugs while it runs. (Lesson 36) - Separate chaining: Handling hash collisions by keeping a linked list of entries in each bucket. (Lesson 28)
- Shell: A program that reads commands and runs them, such as
bashorzsh. (Lesson 29) - Signed integer overflow: Going past the largest or smallest value of a signed type such as
int. It is undefined behavior, unlike unsigned arithmetic, which wraps around. (Lesson 37) - Socket: An endpoint for network communication, used like a file descriptor with
sendandrecv. (Lesson 26) - Stack: The memory that holds a function's local variables. It is freed automatically when the function returns. (Lesson 13)
- Stack overflow: Running out of stack memory, typically from recursion that never stops. (Lesson 19)
- Statement: One instruction in C, usually ending with a semicolon. (Lesson 1)
static: Inside a function, makes a local variable keep its value between calls. At file scope, makes a name private to its file. (Lesson 24)- Strict aliasing: The rule that an object may only be accessed through its own type (or as raw bytes). Use
memcpyto copy an object's bits into another type. (Lesson 37) - String: In C, an array of
charending with a null terminator. (Lesson 9) - String literal: Text in double quotes, such as
"Hello, World!\n". The compiler adds the null terminator. (Lesson 1) - Stringizing operator (
#): In a macro,#nameturns the argument into a string literal, so a test can print the check exactly as written. (Lesson 38) - Struct: A user-defined type that groups related variables, possibly of different types, under one name. (Lesson 12)
T
- Test harness: The code that runs tests and reports the results, such as lesson 38's
CHECKmacro and its counters. (Lesson 38) - Thread: A path of execution inside a process. Threads of one process share its memory. (Lesson 30)
U
- Undefined behavior: Code whose result the C standard does not define, such as reading past the end of an array. Anything can happen, including appearing to work. (Lesson 8)
- UndefinedBehaviorSanitizer (UBSan): A sanitizer, turned on with
-fsanitize=undefined, that reports undefined behavior such as signed overflow and bad shifts while the program runs. (Lesson 37) - Union: A type whose members share the same memory, so it holds only one of them at a time. (Lesson 23)
- Unit test: A test of one small piece of code, usually one function, on inputs whose correct results you already know. (Lesson 38)
V
- Variable: A named piece of memory that holds a value of a given type. (Lesson 2)
- Virtual screen: The in-memory copy of the screen that ncurses draws into.
refresh()copies it to the real terminal. (Lesson 33)
W
- Watchpoint: A debugger setting that pauses the program whenever a chosen variable changes. (Lesson 36)