CLA (C language) study materials
CLA (C language) study resources

CLA (C language) key terms

CLA (C language) · Get comfortable with the vocabulary.

translation unit

The complete source text a compiler processes after preprocessing: your .c file with all #include files and macro expansions inserted. Compilation and linkage operate on translation units, not on individual files.

Related: preprocessor directive, object file
preprocessor directive

A line beginning with # that the preprocessor handles before compilation, such as #include, #define, #ifdef, and #pragma. Directives are not C statements and do not end with a semicolon.

Related: macro, include guard, translation unit
macro

A name replaced by text before compilation via #define. Object-like macros substitute a token sequence; function-like macros take arguments and should parenthesize them to avoid precedence surprises.

Related: preprocessor directive, include guard
include guard

A pattern of #ifndef, #define, and #endif around a header's contents so repeated inclusion in one translation unit expands the body only once, preventing duplicate definitions.

Related: header file, preprocessor directive
header file

A file conventionally ending in .h that declares functions, types, and macros shared across source files. It is inserted by #include; definitions of functions and objects normally belong in .c files.

Related: include guard, declaration
declaration

A statement that introduces a name and its type to the compiler without necessarily allocating storage, such as extern int count; or a function prototype. Declarations may repeat across translation units.

Related: definition, function prototype
definition

A declaration that also creates the entity: it allocates storage for an object or supplies a function body. Exactly one definition of an external object or function may exist across the whole program.

Related: declaration, linkage
linkage

The property determining whether a name can be shared across translation units. External linkage is visible program-wide, internal linkage (static at file scope) is limited to one translation unit, and no linkage applies to locals.

Related: definition, storage duration
storage duration

How long an object's storage exists: automatic (block scope, ends at block exit), static (whole program run), or allocated (from malloc until free). Storage duration is distinct from scope.

Related: scope, static variable, dynamic allocation
scope

The region of program text where a declared name is visible: block scope, function prototype scope, file scope, or function scope (labels). Inner declarations can hide outer ones.

Related: storage duration, static variable
static variable

A variable with static storage duration. At file scope, static gives internal linkage. Inside a function, static keeps one persistent copy initialized once, retaining its value between calls.

Related: storage duration, linkage, scope
integer promotion

The automatic conversion of types smaller than int, such as char and short, to int (or unsigned int) in most expressions. This affects arithmetic results and comparisons with unsigned values.

Related: implicit conversion, unsigned integer
implicit conversion

A conversion the compiler inserts without a cast, for example int to double in mixed arithmetic or a wider to narrower integer assignment. Narrowing conversions can silently lose data.

Related: integer promotion, cast, unsigned integer
cast

An explicit conversion written as (type)expression, requesting that a value be converted to the named type. Casts suppress warnings but do not make an unsafe conversion safe.

Related: implicit conversion, void pointer
unsigned integer

An integer type storing only nonnegative values, with wraparound arithmetic modulo one more than its maximum. Mixing signed and unsigned operands in comparisons can convert the signed value unexpectedly.

Related: integer promotion, implicit conversion
short-circuit evaluation

The rule that && stops evaluating once the left operand is false, and || stops once the left operand is true. The unevaluated right side's side effects never occur.

Related: logical operator, sequence point
sequence point

A point in execution where all prior side effects are complete before later ones begin, such as the end of a full expression or a function call. Modifying one object twice between sequence points is undefined behavior.

Related: undefined behavior, short-circuit evaluation
undefined behavior

Program behavior the C standard imposes no requirements on, such as reading past an array bound or dereferencing a null pointer. The compiler may do anything, including appearing to work.

Related: sequence point, null pointer, buffer overflow
function prototype

A declaration giving a function's return type, name, and parameter types, ending in a semicolon. It lets the compiler check argument count and types at each call site.

Related: declaration, parameter, variadic function
parameter

A variable declared in a function's parameter list that receives a copy of the corresponding argument's value on each call. Arrays as parameters decay to pointers.

Related: argument, array decay, function prototype
argument

The expression supplied at a call site whose value is passed to the function's corresponding parameter. In C, arguments are passed by value unless a pointer is passed.

Related: parameter, pass by value
pass by value

C's only argument-passing mechanism: the function receives copies, so assigning to a parameter never changes the caller's variable. To modify a caller's object, pass its address.

Related: argument, pointer, parameter
recursion

A function calling itself, directly or indirectly, with a base case that terminates the calls. Each active call consumes stack space, so deep recursion risks stack overflow.

Related: call stack, stack overflow
variadic function

A function accepting a variable number of arguments, declared with an ellipsis after at least one named parameter, such as printf. Arguments are read with va_start, va_arg, and va_end.

Related: function prototype, format specifier
array decay

The automatic conversion of an array expression to a pointer to its first element in most contexts, losing size information. It is why sizeof on a parameter yields a pointer size, not an array size.

Related: pointer, parameter, sizeof operator
pointer

An object holding the address of another object or function. Its type records the pointed-to type, which determines pointer arithmetic and dereferencing behavior.

Related: dereference, pointer arithmetic, null pointer
dereference

Accessing the object a pointer refers to using the unary * operator, as in *p. The pointer must hold a valid address of a live object of a compatible type.

Related: pointer, null pointer, undefined behavior
pointer arithmetic

Adding or subtracting integers on a pointer moves it in units of the pointed-to type, not bytes. Valid results must stay within the same array or one past its last element.

Related: pointer, array decay, one past the end
null pointer

A pointer value guaranteed not to point to any object, written as NULL or a null pointer constant. Dereferencing it is undefined behavior, so check before use.

Related: dereference, undefined behavior, pointer
void pointer

A pointer to an unspecified type that can hold any object pointer without a cast. It cannot be dereferenced or used in arithmetic until converted to a concrete pointer type.

Related: pointer, cast, dynamic allocation
one past the end

The address immediately after an array's last element. Computing it is legal and supports loop termination tests, but dereferencing it is undefined behavior.

Related: pointer arithmetic, array decay
dynamic allocation

Obtaining memory at run time from the heap with malloc, calloc, or realloc, and releasing it with free. The programmer manages this lifetime; failing to free causes a leak.

Related: heap, memory leak, dangling pointer
heap

The region of memory from which malloc-family functions satisfy allocation requests. Its lifetime is controlled by explicit free calls rather than by block or program scope.

Related: dynamic allocation, memory leak
memory leak

Heap memory that was allocated but is no longer reachable by any pointer and was never freed. The program's memory use grows until it exits or allocation fails.

Related: dynamic allocation, heap, dangling pointer
dangling pointer

A pointer that still holds the address of memory that has been freed or has gone out of scope. Using it is undefined behavior because the storage may already be reused.

Related: dynamic allocation, undefined behavior, memory leak
buffer overflow

Writing past the bounds of an array or allocated block, corrupting adjacent memory. Functions like strcpy and gets cannot check destination size, so bounded alternatives are safer.

Related: undefined behavior, array decay
structure

A user-defined type grouping named members of possibly different types into one object, declared with struct. Members are accessed with the dot operator, or arrow through a pointer.

Related: member access operator, typedef, structure padding
member access operator

The dot (.) selects a member from a structure or union object; the arrow (->) selects a member through a pointer to one. The arrow is shorthand for (*p).member.

Related: structure, pointer
structure padding

Unused bytes the compiler inserts between or after members so each aligns to its required boundary. It makes sizeof a struct exceed the sum of its members' sizes.

Related: structure, sizeof operator
typedef

A declaration creating an alternate name for an existing type, as in typedef struct Node Node;. It defines no new type and is often combined with structs and function pointers for readability.

Related: structure, function pointer
union

A type whose members share one storage area, so only one member's value is meaningful at a time. Its size is at least that of its largest member.

Related: structure, structure padding
function pointer

A pointer storing a function's address, declared like int (*fp)(int). It enables callbacks and dispatch tables; calling through it invokes the pointed-to function.

Related: typedef, pointer, callback
callback

A function passed to another function, usually via a function pointer, so the callee can invoke it later. Common in sorting comparators and event handling.

Related: function pointer
file stream

An abstraction for reading or writing a file, represented by a FILE pointer returned from fopen. Standard streams stdin, stdout, and stderr are opened automatically.

Related: fopen mode, fclose, buffer flushing
fopen mode

The string controlling how fopen opens a file: "r" read, "w" truncate and write, "a" append, with "+" for update and "b" for binary. Choosing the wrong mode silently destroys or fails to create data.

Related: file stream, fclose
fclose

The function that flushes buffered output and releases a stream's resources. Failing to close files risks lost writes and exhausted file descriptors.

Related: file stream, buffer flushing
buffer flushing

Forcing buffered output to be written to its destination, done by fflush or implicitly by fclose and normal program termination. Unflushed data can be lost on abnormal exit.

Related: fclose, file stream
format specifier

The conversion sequence in a printf or scanf format string, such as %d or %lf, telling the function how to interpret the corresponding argument. A mismatch causes undefined behavior.

Related: variadic function, undefined behavior
sizeof operator

A compile-time operator yielding the size in bytes of a type or expression as type size_t. It does not evaluate its operand's side effects, except for variable-length arrays.

Related: array decay, structure padding, size_t
size_t

The unsigned integer type used for object sizes and array indices, returned by sizeof and strlen. Printing it requires %zu; comparing it with a negative int can misbehave.

Related: sizeof operator, unsigned integer
call stack

The runtime structure holding one frame per active function call, with parameters, locals, and return address. Deep recursion or large local arrays can exhaust it.

Related: recursion, stack overflow
stack overflow

The failure that occurs when the call stack's fixed space is exhausted, typically by unbounded recursion or huge local arrays. The program usually terminates abnormally.

Related: call stack, recursion
object file

The compiler's output for one translation unit, containing machine code plus symbol tables. The linker combines object files and libraries into an executable.

Related: translation unit, linkage
logical operator

The operators &&, ||, and ! producing int values 0 or 1 from truth values. Unlike bitwise operators, && and || evaluate their operands as whole conditions with short-circuit behavior.

Related: short-circuit evaluation, integer promotion