YOUR C LEARNING COMPANION

Find your next idea.

REVISION DESK

Bring the ideas
back into focus.

A recap, a useful distinction, and an optional concept check for every chapter. Start with your saved chapters or choose an idea to return to later.

Revision choices are optional and stay in this browser. You choose chapter completion separately.

01What is programming?

Recall three ideas

  • A specification states the allowed inputs, required results, and failure rules.
  • An algorithm describes a method; a program expresses work in a language.
  • A successful build does not establish that the program solves the intended problem.
Explain it in your own words

How would you describe the rules for a canteen bill before writing any C?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Why does a program need precise instructions?
Read the explanation for every choice
  1. The computer follows specified operations, so missing decisions must be made explicit.

    ✓ Correct reasoning. A program needs rules for the situations it handles; an unstated intention is not an instruction.

  2. The computer always guesses the programmer’s intention.

    A programmer’s intended meaning does not replace the language’s rules.

  3. Precise instructions make every program correct.

    Precision helps express a plan, but the plan can still contain a mistake.

General

Connect this topic to other ideas
02How computers follow instructions

Recall three ideas

  • State is the information needed to describe a program’s current situation.
  • A trace records selected steps and their effects on that state.
  • A loop intended to finish needs a reason that it reaches an exit.
Explain it in your own words

What would you record to explain a counter that changes from four to five and then stops?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Must one C source line correspond to exactly one machine instruction?
Read the explanation for every choice
  1. Yes, line breaks define processor operations.

    Source layout does not establish a one-to-one instruction count.

  2. Yes, comments each require a machine instruction.

    Comments are not runtime instructions.

  3. No. Translation and optimization can produce a different arrangement.

    ✓ Correct reasoning. Reason from language semantics before assuming a particular machine-level trace.

General

Connect this topic to other ideas
03CPU, memory, storage, and the operating system

Recall three ideas

  • The processor, working memory, storage, and operating system have different roles.
  • A running process has state that differs from the stored executable file.
  • Saving data requires a suitable successful operation beyond changing a working value.
Explain it in your own words

Why can two running copies of the same program show different current values?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Which distinction helps explain why unsaved work can disappear?
Read the explanation for every choice
  1. RAM and persistent storage are interchangeable.

    Working memory and persistent storage have different roles and persistence properties.

  2. Working memory and persistent storage serve different roles.

    ✓ Correct reasoning. Saving normally writes data to persistent storage; keeping a value in working memory is a different operation.

  3. A CPU permanently saves every intermediate value.

    Executing operations does not automatically create a persistent copy of every value.

General

Connect this topic to other ideas
04Why programming languages exist

Recall three ideas

  • A programming language supplies notation and rules for expressing work.
  • Syntax, meaning, and implementation strategy answer different questions.
  • C types and interfaces help organise work while leaving explicit responsibilities with the programmer.
Explain it in your own words

What would you explain first to someone who asks what int means, before discussing its size?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Can syntactically valid code still implement the wrong plan?
Read the explanation for every choice
  1. Yes. Following the grammar does not prove the intended logic.

    ✓ Correct reasoning. Syntax, language meaning, and the problem’s requirements are different questions.

  2. No, grammar checks every real-world requirement.

    A parser does not know every intended requirement.

  3. No, accepted code must produce the intended answer for all inputs.

    Acceptance alone is not that correctness guarantee.

General

Connect this topic to other ideas
05Why C was created

Recall three ideas

  • C developed from earlier language ideas alongside practical Unix systems work.
  • Types and structured operations helped express systems data beyond machine-specific instructions.
  • Portability still depends on language guarantees and documented environment assumptions.
Explain it in your own words

Which problem helped make C useful for Unix, and why did that not make every C program automatically portable?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Which practical need helped shape C’s early development?
Read the explanation for every choice
  1. Implementing systems software, including Unix.

    ✓ Correct reasoning. C developed alongside Unix and grew from earlier systems-language work.

  2. Guaranteeing that every program works unchanged on every machine.

    C’s history does not remove a program’s implementation and environment assumptions.

  3. Replacing every machine-specific operation with automatic safety checks.

    C still requires explicit attention to bounds, lifetimes, and interfaces.

General

Connect this topic to other ideas
06From source code to a running program

Recall three ideas

  • Saving source, building a program, and running it are separate actions.
  • Headers provide translation information; required definitions must still be supplied.
  • An executable can build successfully and later fail because its runtime environment lacks a resource.
Explain it in your own words

How would you explain a program that translates but fails because a function definition is missing?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

A function was declared but its definition is missing from the build. What does the declaration provide?
Read the explanation for every choice
  1. The complete executable body.

    A declaration describes the function’s interface; its body is a definition.

  2. A guarantee that linking succeeds.

    The build still needs the definitions required by the program.

  3. Information needed to check uses of the function.

    ✓ Correct reasoning. A suitable declaration supports checking calls, but it does not supply the missing body.

C17

Connect this topic to other ideas
07Variables, values, and types

Recall three ideas

  • A name, an object, its type, and its current value are different ideas.
  • Initialisation supplies a starting value; later assignment stores another suitable value.
  • Copying an integer value creates no permanent connection between the objects’ later values.
Explain it in your own words

After copying apples into saved, why can changing apples leave saved unchanged?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

After int saved = apples;, a later assignment changes apples. What happens to saved?
Read the explanation for every choice
  1. saved automatically follows apples.

    The initializer copied an int value; it did not create a live connection between the objects.

  2. saved keeps its copied value until it is changed separately.

    ✓ Correct reasoning. The objects are separate. Changing one does not itself assign to the other.

  3. saved ceases to exist.

    An assignment to apples does not end saved’s lifetime.

C17

Connect this topic to other ideas
08Data types, ranges, and representations

Recall three ideas

  • Types govern values, operations, ranges, and conversions, as well as storage requirements.
  • Unsigned wrapping and ordinary signed overflow follow different rules.
  • C bytes and floating-point formats need implementation-specific properties when exact limits matter.
Explain it in your own words

Which properties would you check before choosing a type for counts and measured lengths?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

What can portable C code assume about sizeof(char)?
Read the explanation for every choice
  1. It is always 8.

    Eight is a common number of bits in a byte, not the value of sizeof(char).

  2. It equals sizeof(int) on every implementation.

    The standard does not require those two sizes to be equal.

  3. It is 1, measured in C bytes.

    ✓ Correct reasoning. A C byte is the size of char. CHAR_BIT specifies how many bits that byte contains.

C17

Connect this topic to other ideas
09Declarations, initialization, and assignment

Recall three ideas

  • A declaration introduces information about a name; some declarations also define an entity.
  • An initializer belongs to a definition and differs from a later assignment expression.
  • Starting-value rules depend on the object’s storage duration and declaration context.
Explain it in your own words

Why is a const object allowed to receive an initial value even though later modification is restricted?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

How does initialization differ from a later assignment?
Read the explanation for every choice
  1. Initialization supplies an initial value; assignment later stores a value in an existing modifiable object.

    ✓ Correct reasoning. Both can involve values, but they occur in different language contexts and can have different rules.

  2. Assignment creates a new variable name every time.

    Assigning to an existing object does not introduce a new identifier.

  3. Every local declaration initializes an int to zero.

    An ordinary automatic int without an initializer does not receive an implicit zero value.

C17

Connect this topic to other ideas
10Reading C: tokens, expressions, and statements

Recall three ideas

  • C recognises tokens and combines them according to grammar.
  • Expressions, declarations, and statements can share punctuation while doing different jobs.
  • Whitespace can separate tokens, and literal text can contain spaces that are data.
Explain it in your own words

How would you separate the parts of int total = count + 1; without calling the whole line an expression?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Why are = and == different tokens?
Read the explanation for every choice
  1. In expressions, = assigns and == compares for equality.

    ✓ Correct reasoning. Their expression roles differ. The = token also appears in initialization syntax, where it is not an assignment expression.

  2. Whitespace decides whether both mean assignment.

    Whitespace does not make these two operators interchangeable.

  3. The compiler chooses their meaning from the programmer’s intention.

    The language’s token and expression rules determine their roles.

C17

Connect this topic to other ideas
11Expressions and operators: meaning before precedence

Recall three ideas

  • Operand types and conversions help determine an operation’s meaning.
  • Precedence and associativity describe grouping, rather than generally fixing evaluation order.
  • Short-circuit logical operators provide specific evaluation guarantees; bitwise operators have different jobs.
Explain it in your own words

Why can a guard using && prevent a division, while adding parentheses alone may not establish an evaluation order?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Does higher operator precedence guarantee earlier evaluation of an operand?
Read the explanation for every choice
  1. Yes, precedence is a timeline.

    Precedence groups expressions; evaluation order is a separate set of rules.

  2. No. Grouping and evaluation order are separate rules.

    ✓ Correct reasoning. Parentheses and precedence help determine expression structure; sequencing rules determine required ordering.

  3. Adding parentheses always fixes unsequenced side effects.

    Grouping alone does not introduce sequencing where the language does not specify it.

C17

Connect this topic to other ideas
12Conditions, choices, and loops

Recall three ideas

  • Conditions choose a path using the state examined at that point.
  • A loop trace should show the test, body, update, and exit.
  • break, continue, and return transfer control according to different enclosing constructs.
Explain it in your own words

What state would you trace to check whether a loop runs zero, one, or one-too-many times?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Why can a while loop execute its body zero times?
Read the explanation for every choice
  1. while always runs once before checking.

    That is not while’s control rule; its condition is checked before entering the body.

  2. The compiler removes every loop.

    Loop behavior follows the program’s semantics, not a universal removal rule.

  3. Its controlling expression can be false at the first check.

    ✓ Correct reasoning. A false initial condition prevents the first body execution.

C17

Connect this topic to other ideas
13Functions: inputs, results, and contracts

Recall three ideas

  • A declaration, definition, and call describe different parts of using a function.
  • C passes argument values to parameters; copied pointers can still access shared targets.
  • A function’s useful contract includes ranges, effects, and failure behavior beyond its type signature.
Explain it in your own words

How can a function change a caller’s object through a pointer while argument passing remains by value?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Does passing a pointer argument change C into pass-by-reference?
Read the explanation for every choice
  1. No. The pointer value is copied, and the copy can refer to a shared object.

    ✓ Correct reasoning. The function may modify a permitted pointed-to object, while its parameter is still a separate pointer object.

  2. Yes, pointer parameters are aliases for the caller’s pointer variable.

    A pointer parameter receives a value; assigning that parameter does not directly assign the caller’s pointer object.

  3. A pointer argument copies the whole pointed-to allocation.

    Copying a pointer value does not copy the objects it refers to.

C17

Connect this topic to other ideas
14Recursion: following separate calls

Recall three ideas

  • A recursive design needs a stopping case and a justified reduction toward it.
  • Each invocation has separate parameters and ordinary automatic local instances.
  • Finite arithmetic, call depth, and repeated work still need explicit limits.
Explain it in your own words

Why does triangle(3) need triangle(2), and which result allows the first waiting addition to finish?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Does merely writing a base-case branch guarantee recursive calls will finish?
Read the explanation for every choice
  1. Yes, the presence of the branch forces every call to reach it.

    A branch that is never reached cannot stop the recursion.

  2. Yes, C guarantees unlimited call depth.

    Resource use and call depth are not unlimited portable guarantees.

  3. No. The calls need justified progress toward a stopping condition and resource limits.

    ✓ Correct reasoning. A sound argument also considers valid inputs, arithmetic, depth, and repeated work.

C17

Connect this topic to other ideas
15Comments: explaining intent in C

Recall three ideas

  • Comments explain intent without becoming ordinary executed operations.
  • Comment replacement, literals, and line splicing affect how source is interpreted.
  • A useful comment records a reason or contract and must stay consistent with the code.
Explain it in your own words

Why can deleting comment characters carelessly change token boundaries or expose unintended source?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Outside literals, why can int/**/count; declare count?
Read the explanation for every choice
  1. The comment is replaced by whitespace, separating the tokens.

    ✓ Correct reasoning. It does not join int and count into a single identifier.

  2. The comment executes before the declaration.

    Comments are handled during translation, not executed as runtime statements.

  3. The characters become the identifier intcount.

    Comment replacement supplies separation instead of concatenating these tokens.

C17

Connect this topic to other ideas
16Qualifiers: read-only access and observable effects

Recall three ideas

  • Qualifiers apply to particular types and access paths in a declaration.
  • const access restricts modification through that path without freezing every alias to a mutable target.
  • volatile, restrict, and atomic facilities have specific contracts that do not replace one another.
Explain it in your own words

What would you inspect to identify which part of a pointer declaration const qualifies?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Does accessing a modifiable object through const int * make the original object globally immutable?
Read the explanation for every choice
  1. No. This access path is read-only, but another permitted access can modify the original object.

    ✓ Correct reasoning. This does not permit modifying an object that was originally defined as const.

  2. Yes, every alias becomes read-only automatically.

    Qualifying one access path does not rewrite all other pointer objects and types.

  3. The pointed-to object is copied into the pointer.

    A pointer value refers to an object; it does not contain a copy of that object.

C17

Connect this topic to other ideas
17Storage classes: duration, scope, and linkage

Recall three ideas

  • Scope, storage duration, and linkage describe different properties.
  • Objects with static storage duration persist for program execution; thread-duration objects are associated with a thread.
  • A storage-class keyword must be read in its declaration context rather than as a universal lifetime shortcut.
Explain it in your own words

How can a local static object outlive one execution of the block while its name stays block-scoped?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

For a file-scope definition static int count;, which properties apply?
Read the explanation for every choice
  1. Static storage duration and internal linkage.

    ✓ Correct reasoning. These describe object duration and identifier linkage; the name is declared at file scope.

  2. Automatic duration limited to one function call.

    A file-scope object does not have ordinary automatic duration.

  3. A fresh dynamic allocation whenever the name is used.

    Referencing the name does not perform a new allocation.

C17

Connect this topic to other ideas
18Constants, constant expressions, and compile-time checks

Recall three ideas

  • Literals, enumeration constants, read-only objects, and constant expressions are distinct categories.
  • A context may require an integer constant expression rather than merely an unchanged runtime value.
  • C23 constexpr objects follow their own rules and do not supply C++ constexpr functions.
Explain it in your own words

Why can two declarations with the same numeric value be accepted in different compile-time contexts?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

In C17, does const int n = 3; alone make n an integer constant expression?
Read the explanation for every choice
  1. Yes, const has the same role as every compile-time constant facility.

    Read-only qualification and integer-constant-expression rules are different concepts.

  2. No. const qualification alone does not satisfy that rule.

    ✓ Correct reasoning. Use a form allowed by the relevant constant-expression context, such as an appropriate enumerator or integer constant.

  3. It makes every array using n invalid in every context.

    A nonconstant bound can instead form a VLA where that facility and context are supported.

C17

Connect this topic to other ideas
19Reading keywords by the job they do

Recall three ideas

  • Keywords become easier to interpret when grouped by their jobs.
  • A spelling can participate in declarations, control flow, or special expression rules depending on its role.
  • New spellings and semantic changes must be associated with the selected C edition.
Explain it in your own words

Choose one keyword and explain its job using a rule and a small example rather than a memorised label.

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

What is the main job of return in a function?
Read the explanation for every choice
  1. Always terminate the entire program immediately.

    Returning from an ordinary called function normally resumes its caller.

  2. Repeat the function body.

    return ends the current invocation rather than starting another iteration.

  3. Finish the current function invocation, supplying a value when required.

    ✓ Correct reasoning. The function’s return type and return statement determine the value rules.

C17

Connect this topic to other ideas
20C keyword index: C17 and C23

Recall three ideas

  • This index is a lookup aid linked to the corresponding theory chapters.
  • Keyword status and familiar header macros can differ between C17 and C23.
  • Recognising a spelling is the start of understanding its constraints and useful contexts.
Explain it in your own words

How would you check whether a familiar spelling is a keyword or a header macro in the edition you use?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Is printf a C language keyword?
Read the explanation for every choice
  1. Yes, every standard library name is a keyword.

    Library identifiers and language keywords are separate categories.

  2. No. It names a standard library function declared through <stdio.h>.

    ✓ Correct reasoning. Including a header supplies declarations; it does not turn the name into a language keyword.

  3. It becomes a keyword only after its first call.

    Calling a function does not change the lexical category of its identifier.

C17

Connect this topic to other ideas
21Objects and memory

Recall three ideas

  • Objects occupy storage and have types, representations, and lifetimes.
  • sizeof measures C bytes; CHAR_BIT describes how many bits one C byte contains.
  • A conceptual memory diagram explains relationships without fixing one physical machine layout.
Explain it in your own words

Which facts about an object are guaranteed by C, and which details would you check on the target implementation?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Does C require all ordinary local objects to occupy a physical stack?
Read the explanation for every choice
  1. Yes, a fixed stack layout is part of every C object’s type.

    A type does not prescribe a universal machine stack layout.

  2. No. Storage-duration and lifetime rules do not mandate that physical arrangement.

    ✓ Correct reasoning. A call stack is a useful common implementation model, with limits that should be stated.

  3. No local object can be optimized.

    Implementations can optimize while preserving required program behavior.

C17

Connect this topic to other ideas
22Scope, lifetime, and storage duration

Recall three ideas

  • Scope describes name visibility; lifetime describes when an object exists.
  • Storage duration determines lifetime rules rather than one universal stack diagram.
  • A pointer cannot extend a target object’s lifetime merely by retaining its address.
Explain it in your own words

Why can returning an address of an ordinary automatic local object leave the caller without a usable target?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

An inner block has ended. What happens to a static local declared inside it?
Read the explanation for every choice
  1. Its object remains alive, while that name is outside its block scope here.

    ✓ Correct reasoning. Static storage duration and block scope answer different questions.

  2. Its object must be destroyed at block exit.

    That describes ordinary automatic storage, not a static local’s storage duration.

  3. Its name becomes globally visible.

    Static storage duration does not turn a block-scope identifier into a file-scope identifier.

C17

Connect this topic to other ideas
23Understanding pointers

Recall three ideas

  • A pointer object stores a pointer value and is separate from its target.
  • Copying a pointer copies a relationship without copying or extending the target.
  • Valid access needs the right target, lifetime, range, type, and permissions.
Explain it in your own words

After q copies p, what changes when p is redirected, and what happens if you then write through q?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

After q = p;, p is redirected to another live object. What happens to q?
Read the explanation for every choice
  1. q automatically follows the new p.

    The assignment copied a pointer value, not an ongoing dependency on p.

  2. q retains its earlier pointer value unless separately changed.

    ✓ Correct reasoning. The pointer objects are separate even when their values refer to the same target.

  3. The old target is freed automatically.

    Redirecting a pointer does not itself release the old target’s storage.

C17

Connect this topic to other ideas
24Understanding arrays

Recall three ideas

  • An array contains a contiguous sequence of elements of one type.
  • Valid indexes identify existing elements, while the one-past pointer is a boundary rather than an element.
  • Count and range information must remain consistent with the available storage.
Explain it in your own words

How would you explain the difference between an element count and the largest valid index?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

An array has three elements. What is its last valid element index?
Read the explanation for every choice
  1. 3

    Indices begin at zero, so index 3 would be outside the three elements.

  2. It depends on the first stored value.

    Element values do not change the indexing range.

  3. 2

    ✓ Correct reasoning. The element indices are 0, 1, and 2.

C17

Connect this topic to other ideas
25Arrays and pointers together

Recall three ideas

  • An array object and a pointer object have different types and roles.
  • Many array expressions convert to a pointer to their first element.
  • An adjusted array parameter is a pointer, so its sizeof does not recover the caller’s array size.
Explain it in your own words

Why should a function receiving an array view also receive an appropriate element count?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

For int a[3], what is permitted for the pointer a + 3?
Read the explanation for every choice
  1. Form it as one-past, but do not dereference it.

    ✓ Correct reasoning. The one-past value is a permitted boundary; it does not designate an array element to read.

  2. Read *(a + 3) because the pointer can be formed.

    Being allowed to form a pointer does not make every dereference valid.

  3. It necessarily points to another object.

    C provides no guarantee of another usable object at that boundary.

C17

Connect this topic to other ideas
26Characters, buffers, and strings

Recall three ideas

  • A C string ends at its first null character and needs storage for that terminator.
  • Capacity measures available storage; strlen measures units before the terminator in a valid string.
  • Copies require valid regions, enough space, and the operation’s overlap contract.
Explain it in your own words

What must be true before a string function can safely scan a character buffer?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

char text[6] = "cat"; What are its capacity and strlen result?
Read the explanation for every choice
  1. Capacity 3, length 6.

    This reverses the array’s element count and the character count before the first null.

  2. Capacity 6, length 3.

    ✓ Correct reasoning. The array has six elements; strlen excludes the terminating null and stops before it.

  3. Capacity 6, length 6.

    Extra zero-initialized elements do not extend the string past its first null.

C17

Connect this topic to other ideas
27Text, Unicode, UTF-8, and locale

Recall three ideas

  • Storage units, Unicode scalar values, grapheme clusters, and display width measure different things.
  • UTF-8 validation does not automatically provide normalization or grapheme boundaries.
  • Locale-dependent C conversions require their stated state and error-handling rules.
Explain it in your own words

Why might two strings showing the same accented letter have different strlen results?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

For a valid null-terminated UTF-8 string in an 8-bit-byte char buffer, does strlen count visible letters?
Read the explanation for every choice
  1. No. It counts char elements before the first null, not grapheme clusters.

    ✓ Correct reasoning. UTF-8 code points can use several bytes, and one visible unit can involve several code points.

  2. Yes, every visible letter is exactly one C char.

    That is not a general Unicode or UTF-8 guarantee.

  3. It automatically decodes and normalizes all Unicode text.

    strlen searches for the terminating null; it is not a Unicode normalization operation.

C17

Connect this topic to other ideas
28Dynamic memory and ownership

Recall three ideas

  • Allocation requests a region whose size is chosen while the program runs.
  • The program must validate size arithmetic, handle failure, and establish usable values.
  • Ownership and borrowing rules determine release and the validity of aliases.
Explain it in your own words

How would you replace an allocation while keeping the original pointer available if resizing fails?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

For a positive requested size, realloc fails and returns NULL. What remains valid?
Read the explanation for every choice
  1. The old allocation has always been freed.

    For this positive-size failure, the old allocation is not deallocated.

  2. The new third element is ready to use.

    A failed growth request did not create that extra space.

  3. The original allocation, reachable through the preserved owning pointer.

    ✓ Correct reasoning. Use a temporary result so a failed call does not overwrite the pointer needed to access and release the original allocation.

C17

Connect this topic to other ideas
29Understanding memory mistakes

Recall three ideas

  • Bounds, lifetime, type, and ownership failures are different memory mistakes.
  • A non-null pointer can still be invalid for the requested access.
  • Diagnostic tools provide evidence for exercised cases rather than a proof of all possible executions.
Explain it in your own words

Which checks would distinguish a buffer overrun from a use-after-free in a small failing example?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Does assigning NULL to one pointer repair every alias after free?
Read the explanation for every choice
  1. No. Other pointer objects do not update automatically.

    ✓ Correct reasoning. Ownership and alias lifetimes need a contract; clearing one pointer only changes that pointer object.

  2. Yes, free finds and clears all aliases.

    free releases allocated storage; it does not locate and rewrite all pointer objects.

  3. Yes, NULL releases the same allocation again.

    Assigning NULL is an assignment, not another deallocation operation.

C17

Connect this topic to other ideas
30Structures: related data

Recall three ideas

  • A structure type describes named members, and each structure object holds member values.
  • A contained array belongs to the structure object; a pointer member can refer elsewhere.
  • Member types and relationships determine which record states make sense.
Explain it in your own words

Why does a record with a pointer member need a lifetime contract for the referenced data?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

What happens to a pointer member during ordinary structure assignment?
Read the explanation for every choice
  1. Its entire pointed-to allocation is duplicated automatically.

    Structure assignment does not provide an automatic deep-copy ownership policy.

  2. The pointer value is copied, so both members can refer to the same object.

    ✓ Correct reasoning. Any ownership or independent-copy requirement needs an additional contract.

  3. The original allocation is released.

    Assigning a structure does not itself call free on pointer members.

C17

Connect this topic to other ideas
31Structure values and functions

Recall three ideas

  • Copying a structure copies its member values.
  • A copied pointer member can keep two records connected to the same target.
  • Logical comparison and external serialization require policies beyond copying object bytes.
Explain it in your own words

Which changes affect only a copied record, and which can affect a shared pointer target?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

A function receives a structure by value. Which change can affect an object shared with its caller?
Read the explanation for every choice
  1. Assigning a new integer directly to the copied structure’s int member.

    That member belongs to the separate parameter object.

  2. A permitted write through a copied pointer member that still refers to the shared object.

    ✓ Correct reasoning. Copying a structure does not automatically copy the objects its pointer members refer to.

  3. Changing any parameter necessarily replaces the caller’s whole structure.

    The structure parameter is a separate object.

C17

Connect this topic to other ideas
32Enumerations: named choices

Recall three ideas

  • Enumeration constants provide meaningful names for choices.
  • The language rules for values and types differ in specific C17 and C23 cases.
  • External integers still need validation against the application’s accepted choices.
Explain it in your own words

Why should a menu command read from a file be checked before treating it as a named enum choice?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

With enum State { IDLE = 2, BUSY = 7 };, must BUSY have value 3?
Read the explanation for every choice
  1. Yes, an enum ignores explicitly supplied values.

    Explicit enumerator initializers are meaningful.

  2. Its value changes each time it is read.

    An enumerator is a named integer constant, not a runtime counter.

  3. No. BUSY is explicitly given the value 7.

    ✓ Correct reasoning. Sequential defaults do not override an explicit initializer.

C17

Connect this topic to other ideas
33Unions and tagged data

Recall three ideas

  • Union members share storage rather than each receiving separate simultaneous storage.
  • A tag can identify which interpretation the program intends.
  • The program must preserve the relationship between the tag, stored data, and permitted accesses.
Explain it in your own words

What should an update do to keep a tagged union’s chosen form and data consistent?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

In a tagged-union design, who keeps the tag consistent with the intended payload?
Read the explanation for every choice
  1. The program, through its construction and access contract.

    ✓ Correct reasoning. Assigning a union member does not automatically update a separate tag field.

  2. The union updates every separate tag automatically.

    C provides no such automatic relationship for an ordinary separate tag field.

  3. No tag is needed because every union member has separate storage.

    Union members share storage; the intended interpretation needs a clear contract.

C17

Connect this topic to other ideas
34Initializing records and aggregates

Recall three ideas

  • Aggregate initialisers set member and element starting values under their type rules.
  • Designators name selected members or elements without changing the object’s layout.
  • Compound literals create objects whose lifetime depends on their context and version-specific rules.
Explain it in your own words

Why can a designated initializer make a record’s intended starting state clearer to a reader?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

In int a[3] = {1};, how are the remaining two elements initialized?
Read the explanation for every choice
  1. They both repeat 1.

    A partial initializer does not repeat the last explicitly supplied value.

  2. They are initialized to zero.

    ✓ Correct reasoning. The remaining aggregate elements receive the implicit initialization specified by the language.

  3. They must contain arbitrary uninitialized values.

    This aggregate has an initializer; its omitted elements are not treated like an uninitialized automatic int.

C17

Connect this topic to other ideas
35Padding, alignment, and layout

Recall three ideas

  • Alignment constrains which storage positions are suitable for a type.
  • Structure padding can make sizeof exceed the sum of member sizes.
  • Layout details and bit-field behavior need implementation-aware checks and explicit external-format rules.
Explain it in your own words

Why can comparing complete structure bytes fail to express the equality your application wants?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Do equal meaningful structure-member values guarantee identical object bytes?
Read the explanation for every choice
  1. Yes, every structure contains only its meaningful values and no padding.

    Implementations can insert padding, and representations need not provide this general guarantee.

  2. No. Padding and representations can make byte comparison unsuitable for value equality.

    ✓ Correct reasoning. Compare meaningful members according to the equality your program intends.

  3. memcmp always performs a member-by-member semantic comparison.

    memcmp compares bytes, not the meanings of structure members.

C17

Connect this topic to other ideas
36Flexible array members

Recall three ideas

  • A flexible array member supports trailing elements after a structure’s fixed members.
  • Checked allocation arithmetic must provide storage for the intended tail.
  • Logical length, initialised payload, and actual capacity must stay consistent.
Explain it in your own words

Which calculations and initialisations are needed before a flexible-array record can expose its payload?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Does setting a count field allocate space for a flexible array member?
Read the explanation for every choice
  1. Yes, the array grows automatically to match the count.

    A count assignment does not acquire storage.

  2. Yes, sizeof the header always includes any desired payload.

    The type’s fixed size does not supply arbitrary extra payload capacity.

  3. No. The allocation must separately provide sufficient checked capacity.

    ✓ Correct reasoning. Keep the count, allocation size, and bounds consistent; check size arithmetic before allocating.

C17

Connect this topic to other ideas
37Types, declarations, and data interfaces

Recall three ideas

  • A typedef gives a type another name and can hide pointer details.
  • Qualifiers apply to the actual aliased type, so declarator structure matters.
  • Useful data interfaces state valid states, mutation, ownership, lifetime, and failure behavior.
Explain it in your own words

How can a pointer typedef change the meaning you first expect from a const declaration?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

In int *a, b;, which declarator declares a pointer?
Read the explanation for every choice
  1. Both a and b.

    The star belongs to a’s declarator, not automatically to every name in the declaration.

  2. Only b.

    The star is attached to a’s declarator.

  3. Only a; b has type int.

    ✓ Correct reasoning. Read each declarator separately with the shared type specifier.

C17

Connect this topic to other ideas
38Function pointers and callbacks

Recall three ideas

  • A function pointer selects a function without copying its code.
  • An indirect call must use a compatible function type and meet the called function’s contract.
  • A callback’s timing, context data, and concurrency rules come from the receiving API.
Explain it in your own words

What agreement does a caller need before giving another operation a callback and a data pointer?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Can a cast alone repair a callback whose function type is incompatible with the required callback type?
Read the explanation for every choice
  1. No. The eventual call must use a compatible function type.

    ✓ Correct reasoning. A cast does not change the function’s parameter and return contract.

  2. Yes, casting rewrites the function’s parameter types.

    Converting a pointer does not rewrite the function’s definition.

  3. Yes, every pointer type has identical call semantics.

    Object and function pointer roles and compatible function types still matter.

C17

Connect this topic to other ideas
39Preprocessing: preparing the source

Recall three ideas

  • Preprocessing handles directives and replacement before ordinary C semantic analysis.
  • A preprocessor condition selects source rather than testing a runtime object.
  • Configuration choices must leave valid declarations and compatible interfaces in the included source.
Explain it in your own words

How does #if selecting source differ from an ordinary if choosing a runtime path?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

How does #if differ from an ordinary if?
Read the explanation for every choice
  1. Both select runtime branches in the same way.

    #if is handled during preprocessing rather than as an ordinary runtime statement.

  2. #if selects source during preprocessing; if selects a path in ordinary execution.

    ✓ Correct reasoning. Conditional inclusion determines which source tokens proceed into later translation.

  3. #if can inspect every runtime variable’s current value.

    Preprocessing condition rules do not provide access to future runtime object values.

C17

Connect this topic to other ideas
40Macros: tokens, arguments, and pitfalls

Recall three ideas

  • Macros replace preprocessing tokens rather than receiving typed argument values like functions.
  • Parentheses can repair grouping without preventing repeated evaluation.
  • Stringizing, token pasting, and conditional forms require their specific preprocessing rules.
Explain it in your own words

Why might a small typed function be a clearer choice than a function-like macro with a side-effecting argument?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

A macro uses its parameter twice. Why can a side-effecting argument be risky?
Read the explanation for every choice
  1. Macro arguments are always evaluated exactly once.

    Token substitution does not provide a function-call-style single evaluation guarantee.

  2. Expansion can evaluate that expression more than once, with sequencing concerns.

    ✓ Correct reasoning. Inspect the replacement tokens and sequencing; do not invent an output for an invalid expansion.

  3. Parentheses automatically remove every repeated side effect.

    Parentheses can improve grouping without removing duplicated evaluations.

C17

Connect this topic to other ideas
41Headers: sharing an interface

Recall three ideas

  • Headers share interface information needed during translation.
  • Guards can prevent repeated inclusion within a translation unit.
  • A header must be designed around declarations and any definitions permitted by the relevant linkage rules.
Explain it in your own words

What should a header include to remain usable when another source file includes it by itself?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Why place shared function declarations in a header?
Read the explanation for every choice
  1. Including a header always links a library.

    Header inclusion and supplying compiled definitions are separate build concerns.

  2. A header is a separate running program.

    Headers supply source through inclusion; they do not run as independent programs.

  3. To share a consistent interface across translation units.

    ✓ Correct reasoning. The declarations can be included where functions are used and where their definitions are checked.

C17

Connect this topic to other ideas
42Translation units and linkage

Recall three ideas

  • Each translation unit has its own preprocessing and declaration context.
  • Linkage connects declarations referring to the same entity across appropriate contexts.
  • Shared interfaces require compatible declarations and the correct program-level definitions.
Explain it in your own words

How can two files both translate yet disagree about the interface of the entity they try to share?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Do two file-scope static objects in different translation units have to be the same object because their names match?
Read the explanation for every choice
  1. No. Their identifiers have internal linkage in their respective translation units.

    ✓ Correct reasoning. Matching spelling does not establish shared external identity for internal-linkage identifiers.

  2. Yes, every matching spelling names one global object.

    Scope and linkage rules matter; matching text alone is insufficient.

  3. static always means block scope.

    static can appear in file-scope declarations too; scope depends on declaration location.

C17

Connect this topic to other ideas
43Linking and libraries

Recall three ideas

  • Linking connects references with the definitions supplied to a build.
  • Static archives and shared libraries package components under toolchain-specific rules.
  • A compatible name alone does not establish the full ABI and ownership contract.
Explain it in your own words

Which evidence would separate a missing definition from an incompatible declaration or unavailable shared dependency?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

What is the difference between seeing a library declaration and supplying its definition?
Read the explanation for every choice
  1. The declaration supports type checking; the build still needs the required implementation.

    ✓ Correct reasoning. How a toolchain supplies library definitions is separate from header inclusion.

  2. Including a header always builds every library on the computer.

    Header inclusion supplies source declarations, not a universal library-build operation.

  3. Every C implementation requires the same library command-line flags.

    Toolchain flags are implementation-specific interfaces.

C17

Connect this topic to other ideas
44The standard library: facilities and contracts

Recall three ideas

  • Library facilities are organised by the jobs they support.
  • Each call has argument, storage, result, and failure rules.
  • Hosted, freestanding, optional, and platform-specific facilities have different availability contracts.
Explain it in your own words

What would you check in a library function’s documentation before passing it a pointer and a count?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Does a valid library declaration make every call valid?
Read the explanation for every choice
  1. Yes, the library repairs all invalid pointers.

    A library interface does not remove the caller’s pointer and lifetime obligations.

  2. Yes, a header guarantees successful resource acquisition.

    Operations such as allocation and file opening can still fail.

  3. No. The caller must also satisfy the function’s argument and state contracts.

    ✓ Correct reasoning. Bounds, formats, lifetimes, and error handling remain part of correct use.

C17

Connect this topic to other ideas
45Modular programs: contracts and builds

Recall three ideas

  • A module should have a coherent responsibility and a clear interface.
  • Private representation and helpers can reduce the state other code must understand.
  • Build dependencies must account for shared interface changes, as well as implementation files.
Explain it in your own words

How would you describe a module’s accepted inputs and unchanged-on-rejection policy to another programmer?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

In an ordinary two-file module build, how are an interface and its implementation supplied?
Read the explanation for every choice
  1. Including the interface header automatically supplies every definition.

    Declarations in a header do not automatically link function bodies.

  2. The caller should guess the function’s type.

    A consistent declaration is needed for checking the interface.

  3. Share declarations through a header and include the implementation source in the build.

    ✓ Correct reasoning. The build must translate and connect the definitions the program requires.

C17

Connect this topic to other ideas
46Arguments, conversion, and the environment

Recall three ideas

  • Command-line arguments are strings supplied through the hosted startup interface.
  • Parsing a number and accepting an application value are separate checks.
  • Borrowed environment strings have availability and invalidation rules.
Explain it in your own words

Which checks would you use before accepting one command-line argument as a level from zero through 100?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

If a command-line argument exists, is it already a valid number?
Read the explanation for every choice
  1. Yes, argv converts numeric-looking text automatically.

    argv supplies strings; it does not perform numeric validation.

  2. No. Parse it and check the accepted syntax and range.

    ✓ Correct reasoning. Presence, conversion success, and acceptable value range are separate checks.

  3. Yes, argc records the numeric value of every argument.

    argc counts arguments; it does not describe their numeric contents.

C17

Connect this topic to other ideas
47Variadic functions: arguments need an agreement

Recall three ideas

  • Trailing variadic arguments need an explicit count and type agreement.
  • Default argument promotions affect which type va_arg must retrieve.
  • Each va_start or va_copy traversal needs the corresponding va_end.
Explain it in your own words

Why does a float passed after the ellipsis need to be retrieved as double?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

A float value is passed through ... in a prototyped variadic call. What type does its default argument promotion supply?
Read the explanation for every choice
  1. float, with no change.

    Default argument promotions apply to arguments corresponding to the ellipsis.

  2. double.

    ✓ Correct reasoning. The receiving variadic code must follow the promoted-type agreement, not retrieve it as float.

  3. A pointer to the caller’s float object.

    This is a value conversion, not an implicit address-taking operation.

C17

Connect this topic to other ideas
48Searching and sorting by a comparison rule

Recall three ideas

  • A comparator supplies a consistent ordering through the sign of its result.
  • qsort may reorder equal elements and does not promise a particular sorting algorithm.
  • bsearch needs the required key-relative arrangement and may return any equal match.
Explain it in your own words

What must stay consistent between sorting an array and searching it with a comparison callback?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Why can return a - b; be a bad comparison rule for arbitrary int values?
Read the explanation for every choice
  1. A comparator must always return exactly 1.

    A comparison rule must distinguish less, equal, and greater with the required signs.

  2. All subtraction results are automatically Boolean.

    Ordinary integer subtraction is not restricted to zero and one.

  3. Signed subtraction can overflow and fail to express a valid ordering.

    ✓ Correct reasoning. Use safe comparisons and a consistent ordering contract instead of relying on a potentially overflowing difference.

C17

Connect this topic to other ideas
49Streams, buffering, and EOF

Recall three ideas

  • A stream is a C interface to a sequence, distinct from its underlying device.
  • A read result must be checked before the program treats it as a character.
  • Buffering, end-of-file indicators, and error indicators have separate meanings.
Explain it in your own words

Why should a character read be stored in int and checked before narrowing it to char?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Why retain fgetc’s result in int until checking EOF?
Read the explanation for every choice
  1. Because int always stores exactly one visible letter.

    The purpose is preserving the function’s return interface, not a universal letter representation.

  2. Premature conversion to char can lose information needed by the return-value check.

    ✓ Correct reasoning. Keep the return type and inspect the stream’s EOF/error state as the interface requires.

  3. EOF is an extra character stored at the end of every file.

    EOF is an integer indicator used by the interface, not a required stored file character.

C17

Connect this topic to other ideas
50Formatted output and format contracts

Recall three ideas

  • Formats must match the supplied argument types after the relevant promotions.
  • Width, precision, and destination capacity solve different formatting questions.
  • Output errors and truncation must be checked under the chosen function’s rules.
Explain it in your own words

What would you check after snprintf before treating its buffer as the complete requested message?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

What must a printf conversion agree with?
Read the explanation for every choice
  1. Only how many characters the output should look like.

    Appearance does not establish a valid argument type for a conversion.

  2. Only the variable’s name.

    Identifier spelling does not communicate the argument’s required type.

  3. The actual argument type after the applicable argument promotions.

    ✓ Correct reasoning. The format string is a contract; it does not generally convert a mismatched argument into the required type.

C17

Connect this topic to other ideas
51Formatted input: matching and limits

Recall three ideas

  • Formatted input can stop after a partial match or a failed conversion.
  • Destination types and field widths must match the conversion contract and available storage.
  • Numeric input whose converted value cannot be represented needs particular care with scanf-family rules.
Explain it in your own words

Why is a successful first conversion insufficient evidence that the whole requested input record was accepted?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Why check scanf’s return value before using the result of a counted conversion?
Read the explanation for every choice
  1. An input conversion can fail before storing that result.

    ✓ Correct reasoning. Check the expected number of counted assignments before using the results; %n is excluded from that count.

  2. scanf always fills every destination with zero first.

    A failed conversion does not promise to initialize the destination to zero.

  3. A width limit guarantees valid numeric range.

    A field width limits consumed input; it is not a general numeric-range validation strategy.

C17

Connect this topic to other ideas
52Lines, boundaries, and checked parsing

Recall three ideas

  • A complete input record must be separated from chunks returned by an input call.
  • Parsing should distinguish valid data, incomplete input, invalid text, and out-of-range values.
  • Accepted values should be committed only after the required checks succeed.
Explain it in your own words

How would you reject an overlong line while leaving the next input record ready to read?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

If fgets succeeds, must it have consumed one whole input line?
Read the explanation for every choice
  1. Yes, a terminating null proves the whole line fitted.

    Null termination does not prove that a newline or the entire logical line was consumed.

  2. Yes, the buffer size automatically grows.

    fgets does not dynamically enlarge the supplied buffer.

  3. No. The buffer can fill before the line ends.

    ✓ Correct reasoning. Detect and handle incomplete lines according to the input policy.

C17

Connect this topic to other ideas
53Opening files, modes, and lifetimes

Recall three ideas

  • An opening mode chooses reading, creation, replacement, append, or update behavior.
  • The opening operation can fail or modify a file before a later write.
  • Stream ownership includes the appropriate close operation and its possible failure.
Explain it in your own words

Which mode and failure policy would protect an existing file when the task requires creating a new destination?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

What should you check after fopen before using the stream?
Read the explanation for every choice
  1. Whether the returned pointer is NULL.

    ✓ Correct reasoning. NULL indicates failure to open; using it as a valid stream would violate the interface contract.

  2. Whether the returned pointer equals EOF.

    EOF is an integer macro used by other I/O interfaces, not fopen’s failure pointer.

  3. Only whether the filename contains a dot.

    The filename’s appearance does not prove that opening succeeded.

C17

Connect this topic to other ideas
54Block I/O, positions, and update streams

Recall three ideas

  • Block I/O reports complete transferred elements rather than a promise that the entire request succeeded.
  • Position tokens and text-stream offsets follow specific stream rules.
  • Update streams require the correct transitions between reading and writing.
Explain it in your own words

What would you inspect after a short block read before deciding whether it is a final record or an error?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

What does fwrite return when asked to write several elements?
Read the explanation for every choice
  1. The number of elements successfully written.

    ✓ Correct reasoning. The result counts elements. With an element size of one byte, it also directly gives the byte count.

  2. Always the total requested number of bytes.

    The result reports completed elements and can be short.

  3. A guarantee that no later flush or close can fail.

    Buffered output can encounter errors later; success here is not that broader guarantee.

C17

Connect this topic to other ideas
55Errors, status, errno, and assertions

Recall three ideas

  • Interfaces report failure through their documented status and result conventions.
  • errno is meaningful only under the applicable operation’s error rules.
  • Assertions express program assumptions and cannot replace validation that must run in every build.
Explain it in your own words

Why is a nonzero errno after an unrelated successful operation insufficient evidence of a new failure?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Does a nonzero errno alone prove the last function call failed?
Read the explanation for every choice
  1. Yes, every successful function resets errno.

    Successful functions do not generally promise to clear errno.

  2. Yes, errno replaces every function’s return value.

    Each interface defines its own error indication and when errno is meaningful.

  3. No. Follow that function’s documented failure indication and errno rules.

    ✓ Correct reasoning. The value can be left over from an earlier operation.

C17

Connect this topic to other ideas
56Ownership, cleanup, and partial work

Recall three ideas

  • Cleanup depends on which resources were successfully acquired before a failure.
  • Ownership determines who must release each resource and when references become invalid.
  • Closing resources does not automatically undo external partial work or prove durable storage.
Explain it in your own words

Which resources and partial effects would you track if copying a file fails halfway through?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

A function acquires one resource, then acquiring a second fails. What should its failure path account for?
Read the explanation for every choice
  1. Release every imagined resource, even those never acquired.

    Cleanup must follow actual acquisition state and the resource’s API contract.

  2. Return immediately and leave the first resource owned by nobody.

    Losing ownership can leak the first resource.

  3. Release or transfer the first resource according to the ownership contract.

    ✓ Correct reasoning. Partial work still creates cleanup obligations for resources already acquired.

C17

Connect this topic to other ideas
57Dates, clocks, and measuring time

Recall three ideas

  • Calendar time, elapsed duration, and processor time answer different questions.
  • Calendar fields, conversions, and formatting have conventions and failure cases.
  • Clock availability, resolution, range, and monotonicity must be checked separately.
Explain it in your own words

Why might a program that waits for two seconds use much less than two seconds of processor time?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

What does clock() aim to measure?
Read the explanation for every choice
  1. Always the calendar date as Unix seconds.

    Calendar time and the representation of time_t are separate from clock’s interface.

  2. Processor time used by the program, rather than a general wall-clock stopwatch.

    ✓ Correct reasoning. Check availability and convert using CLOCKS_PER_SEC under the interface’s limits.

  3. The number of source lines executed.

    Source-line counts are not the quantity reported by this clock interface.

C17

Connect this topic to other ideas
58Behavior, guarantees, and undefined behavior

Recall three ideas

  • Undefined, unspecified, and implementation-defined behavior describe different language categories.
  • A language-valid operation can still violate an application’s requirements.
  • Observing one result cannot establish a guarantee that the language does not provide.
Explain it in your own words

How would you decide whether two observed outputs show an allowed choice or an invalid operation?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

A program with undefined behavior appeared to work once. What does that establish?
Read the explanation for every choice
  1. That the operation is portable.

    One observed outcome cannot create a language guarantee.

  2. Only that this run produced that observation.

    ✓ Correct reasoning. The C standard imposes no requirements for undefined behavior; a successful-looking run does not validate the operation.

  3. That the compiler must warn every time.

    A diagnostic is not required for every possible undefined behavior.

C17

Connect this topic to other ideas
59Evaluation order and side effects

Recall three ideas

  • Value computation and side effects can have ordering relationships beyond expression grouping.
  • Specific operators and full-expression boundaries provide sequencing guarantees.
  • Unsequenced conflicting accesses can produce undefined behavior rather than merely multiple possible results.
Explain it in your own words

When two operations must happen in order, how could separate statements make that requirement clearer?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

What ordering does left && right provide?
Read the explanation for every choice
  1. Both operands always run, in either order.

    The right operand is conditionally evaluated, after the left operand.

  2. The left operand is evaluated first; the right is evaluated only if the left is nonzero.

    ✓ Correct reasoning. The logical-AND operator provides short-circuit evaluation and sequencing.

  3. The right operand always runs first.

    That reverses this operator’s required evaluation relationship.

C17

Connect this topic to other ideas
60Effective types, aliases, and access

Recall three ideas

  • Typed access depends on the object, its lifetime, alignment, and the permitted access type.
  • A character representation view does not grant arbitrary typed reinterpretation.
  • restrict is a contract about the relevant accesses, not a generic synonym for “these pointers differ.”
Explain it in your own words

Why can a buffer with enough bytes still be unsuitable for access through a converted typed pointer?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Why is alignment alone insufficient to justify a dereference after a pointer cast?
Read the explanation for every choice
  1. A cast automatically creates a new object of the destination type.

    Changing a pointer’s type does not generally create a new pointed-to object.

  2. A cast makes every possible access type valid.

    The language restricts which types may access an object’s stored value.

  3. Lifetime, access-type rules, and bounds must also permit the operation.

    ✓ Correct reasoning. Character-type representation access does not grant unrestricted permission for arbitrary typed reads.

C17

Connect this topic to other ideas
61Portability and explicit assumptions

Recall three ideas

  • Portable design starts by stating which target properties the program needs.
  • Language guarantees and implementation-specific choices must be kept distinct.
  • Explicit conversions, width checks, and format definitions make assumptions reviewable.
Explain it in your own words

Which assumptions would you document before sharing a two-octet numeric format between two machines?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Must every conforming C17 implementation provide uint32_t?
Read the explanation for every choice
  1. No. Exact-width typedefs are provided when the implementation has a suitable type.

    ✓ Correct reasoning. Do not assume an optional exact-width type exists without checking the implementation’s facilities.

  2. Yes, int is required to be exactly 32 bits.

    C17 does not require a universal 32-bit int.

  3. Yes, including any header creates all integer widths.

    A header cannot create an integer representation the implementation does not support.

C17

Connect this topic to other ideas
62Floating-point calculations and mathematical functions

Recall three ideas

  • Floating-point values have finite range and precision, with rounding under the selected implementation rules.
  • Comparison tolerances must come from an application’s units, domain, and acceptable error.
  • Math domains, special values, and error reporting require explicit policies.
Explain it in your own words

Why could changing an addition order change a floating-point observation without proving the compiler is wrong?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Can portable code assume every math error is reported only through errno?
Read the explanation for every choice
  1. Yes, exceptions and math_errhandling never matter.

    The implementation’s advertised error-handling facilities matter.

  2. Yes, every finite result proves there was no domain or range issue.

    Inspect the relevant function and error contract instead of using that general shortcut.

  3. No. Follow math_errhandling and the relevant function’s result and error rules.

    ✓ Correct reasoning. Applicable errno and floating-point exception reporting must be handled according to the implementation’s contract.

C17

Connect this topic to other ideas
63Defensive C and security boundaries

Recall three ideas

  • Validation includes semantic domains, resource limits, and checked size arithmetic.
  • Pointer and count contracts still require genuinely accessible regions.
  • Defensive choices reduce specified risks while remaining dependent on a clear threat and ownership model.
Explain it in your own words

Which checks belong before calculating and allocating space for an input-controlled number of elements?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

What should happen before copying externally supplied data into a bounded buffer?
Read the explanation for every choice
  1. Trust a claimed length without checking capacity.

    A supplied length is input too; it can violate the receiving buffer’s bounds.

  2. Rename the buffer to make the operation safe.

    Names can communicate intent but cannot enforce a valid copy.

  3. Validate the length, capacity, and arithmetic needed by the copy contract.

    ✓ Correct reasoning. If a C string is required, account for its terminator as part of that contract.

C17

Connect this topic to other ideas
64External data formats: an agreement about bytes

Recall three ideas

  • An external format defines fields and encodings independently of a structure’s raw layout.
  • Width, octet order, version, and length rules belong in the reader/writer agreement.
  • Validate the complete record before committing results, and handle partial input explicitly.
Explain it in your own words

Why is an exact expected-byte test useful in addition to an encoder/decoder round trip?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Does binary file mode make a raw structure dump a portable exchange format?
Read the explanation for every choice
  1. No. Layout, padding, byte order, and representations still need an explicit format agreement.

    ✓ Correct reasoning. Define the fields and encoding, then serialize and validate them deliberately.

  2. Yes, binary mode standardizes every structure’s layout.

    Binary mode does not impose a universal structure representation.

  3. Yes, sizeof alone describes the complete external protocol.

    A local byte size does not specify the meanings or encoding of those bytes.

C17

Connect this topic to other ideas
65Threads, atomics, and shared state

Recall three ideas

  • Shared mutable state needs the required access and ordering rules.
  • Atomic operations do not automatically make a larger multi-step update a transaction.
  • Synchronization, resource lifetimes, and API support must all fit the design.
Explain it in your own words

Why does publishing a flag need an ordering agreement for the ordinary data associated with it?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Does volatile alone make conflicting shared accesses safe between C threads?
Read the explanation for every choice
  1. Yes, volatile is a thread lock.

    volatile is not a mutex and does not by itself provide atomicity or synchronization.

  2. No. A suitable synchronization or atomic-access design is still needed.

    ✓ Correct reasoning. Conflicting unsynchronized non-atomic accesses can form a data race.

  3. Every access becomes an indivisible operation.

    volatile does not generally turn ordinary operations into atomic operations.

C17

Connect this topic to other ideas
66Diagnostics, debugging, and evidence

Recall three ideas

  • A useful bug report makes a failure reproducible and states the expected behavior.
  • Diagnostics, debugger observations, and sanitizers answer different questions.
  • A regression check should exercise the boundary or assumption that caused the failure.
Explain it in your own words

What evidence would let someone else investigate your failure without guessing your compiler options or input?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

What does a clean sanitizer run establish?
Read the explanation for every choice
  1. No covered problem was reported in the executions exercised.

    ✓ Correct reasoning. This is useful evidence, but it is not proof for every input, path, or tool limitation.

  2. Every possible execution is valid C.

    A finite test run does not explore every possible execution.

  3. The implementation no longer needs language rules.

    Tools complement the language rules; they do not replace them.

General

Connect this topic to other ideas
67Style, contracts, and code review

Recall three ideas

  • Readable names and interfaces make assumptions easier to inspect.
  • Validation and state updates should have a deliberate, reviewable order.
  • Style guidelines complement the language rules and the application contract.
Explain it in your own words

Which naming or control-flow change would make a function’s rejection path easier to review?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Can clear naming and indentation replace an ownership contract?
Read the explanation for every choice
  1. Yes, formatting automatically releases resources.

    Formatting does not perform runtime cleanup.

  2. No. They help communicate a contract that still needs to be designed and followed.

    ✓ Correct reasoning. Readable code makes reasoning easier without making every operation correct automatically.

  3. Yes, a descriptive pointer name proves its lifetime.

    A name is not evidence that an object is still alive.

General

Connect this topic to other ideas
68C’s timeline: history, editions, and standards

Recall three ideas

  • C’s published editions and working drafts have different status.
  • A nickname such as C23 can differ from the ISO publication year.
  • An older resource should be interpreted using its intended edition and current implementation support.
Explain it in your own words

Which dates and version claims would you check before using a feature from an older book or a compiler preview mode?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Why identify the language edition when reading an old C example?
Read the explanation for every choice
  1. Every old convention is required by modern C.

    Historical practice and a current language requirement are different things.

  2. Rules and available features can differ between editions.

    ✓ Correct reasoning. Check the example’s edition and assumptions before treating it as a portable rule.

  3. A publication date alone proves compiler support.

    Implementation support must be checked separately from a standard’s publication.

General

Connect this topic to other ideas
69Why C looks this way: design and tradeoffs

Recall three ideas

  • C features connect practical systems needs with explicit language contracts.
  • Efficiency and portability depend on program choices and implementation conditions.
  • Understanding a tradeoff is more useful than treating compact syntax as a complete explanation.
Explain it in your own words

Choose one C feature and explain both the problem it helps solve and the responsibility it leaves with the programmer.

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

What responsibility accompanies C’s direct control of objects and storage?
Read the explanation for every choice
  1. Every invalid access is automatically rejected at runtime.

    C does not promise a runtime check for every invalid operation.

  2. Pointer syntax removes the need to know bounds.

    A pointer value does not generally carry a complete bounds contract.

  3. The program must respect bounds, lifetimes, and operation contracts.

    ✓ Correct reasoning. Direct control is useful when the program also maintains the conditions required for valid operations.

C17

Connect this topic to other ideas
70C’s influence: languages, runtimes, and interfaces

Recall three ideas

  • Historical influence, similar syntax, implementation language, and foreign interfaces are different relationships.
  • A runtime written in C does not give its language C semantics.
  • Crossing a language boundary still needs compatible ABI, ownership, and lifetime contracts.
Explain it in your own words

What different claims could someone mean when saying another language is based on C?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

If another language uses C-like syntax, should you assume identical C semantics?
Read the explanation for every choice
  1. No. Learn that language’s own type, lifetime, and operation rules.

    ✓ Correct reasoning. Syntax influence does not establish identical behavior.

  2. Yes, matching braces imply matching memory rules.

    Braces alone do not define an entire language’s memory model.

  3. Yes, every language influenced by C has every C feature.

    Influence can involve selected ideas rather than the whole language.

General

Connect this topic to other ideas
71Modern C: C23 features and adoption

Recall three ideas

  • C23 adds language and library features with their own contracts.
  • Compiler support, library support, and target availability are separate checks.
  • New syntax does not remove bounds, lifetime, range, or argument-type requirements.
Explain it in your own words

How would you verify a new C23 facility before depending on it in a program intended for several toolchains?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

Before relying on a C23 feature, what should you check?
Read the explanation for every choice
  1. Only that the source file ends in .c.

    The extension alone establishes neither a language edition nor feature support.

  2. That one unrelated C23 example compiled.

    Support for one feature does not prove support for every language and library change.

  3. The selected language mode and actual compiler/library support for the feature.

    ✓ Correct reasoning. Language editions and implementation support are distinct. Use documented support and a relevant feature check where appropriate.

C23 adoption

Connect this topic to other ideas
72Reading complete programs through their contracts

Recall three ideas

  • A complete program joins several object, control-flow, and interface contracts.
  • Success, rejection, and cleanup paths all contribute to the promised behavior.
  • Boundary cases help test the reasoning without proving every possible execution.
Explain it in your own words

Pick one complete example and explain what stays unchanged when it rejects invalid input.

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

A complete example produces its expected output once. What should you examine next?
Read the explanation for every choice
  1. Its input assumptions, boundaries, failures, and resource handling.

    ✓ Correct reasoning. An observed output is one piece of evidence about a larger contract.

  2. Only whether its variable names match another example.

    Names alone do not establish equivalent behavior.

  3. Nothing; one output proves every execution.

    Different inputs and paths can exercise different conditions.

General

Connect this topic to other ideas
73Carry the model forward: review and next steps

Recall three ideas

  • Use the reading path as a map connecting concepts rather than a one-time checklist.
  • Explain a rule, its preconditions, and a boundary before generalising an observed result.
  • Practice, reproducible questions, and learner feedback reveal where the explanation needs another step.
Explain it in your own words

Which idea can you now explain more precisely, and which assumption would you check when applying it to a new program?

Check your reasoning about this idea

Optional. Answers are not saved or sent, and reading stays unrestricted.

What is a useful way to explain a C operation you have learned?
Read the explanation for every choice
  1. Repeat its syntax without its validity conditions.

    The conditions are part of understanding when the operation may be used.

  2. State what it does, why it helps, and which conditions keep it valid.

    ✓ Correct reasoning. Connecting meaning, purpose, and limits supports reasoning beyond a memorized example.

  3. Assume a compiler will prevent every mistake.

    Compiler diagnostics do not cover every invalid operation or incorrect intention.

General

Connect this topic to other ideas
Search all 73 chapters in both languages.EN + HG

Try “pointer”, “why int”, or “undefined behavior”.

Concepts connect. Follow your curiosity.↑ ↓ to explore · Enter to open
MAKE YOURSELF COMFORTABLE

Your reading space

Appearance

A clear canvas with balanced contrast.

Text size

100%
AA

Reading tools

Your data stays in this browser

Export a backup before changing browsers or replacing an older version of the reader.

YOUR PERSONAL MARGINS

My notebook

Saved on this device
A LITTLE CLARITY

The glossary

A starting meaning, then a chapter to go deeper.

A QUICK DEFINITION

A little clarity

Read the full explanation →

A thought worth keeping