ProCoreInterview prep

C Errors & Edge Cases

Most C code you have seen handles the case where everything works; this course is about the returns, allocations, and reads that fail, and what checking them properly looks like in practice. It covers return codes versus errno, partial transfers, strtol and strncpy's sharp edges, off-by-one bounds, integer overflow before malloc, and the goto-cleanup and assert idioms that keep a program correct under failure.

Questions90
Topics10
Answering time68 minutes
At five a day18 days
LevelCore

Who it is for

Writes the happy path well.

The behaviour people get wrong after they are already productive in the language.

You will get the most out of it if you have written C recently enough to read it without effort, and have been surprised by it at least once. If you are picking the language up for the first time, start with C Essentials and come back to this one.

It is also built for interview preparation: the questions are the ones that get asked because they separate people who have read the documentation from people who have hit the behaviour in production.

How long it takes

90 graded questions at roughly 45 seconds each is about 68 minutes of answering in total.

At the default five questions a day, and because the session mixes in your other courses, expect around 18 days — call it 3 weeks — to see everything once, plus a few weeks of thinning reviews after that before it is all mastered.

A question is mastered on the third correct answer, once the gap between reviews has grown past a week — so a course cannot be finished in a weekend however long you sit with it.

Question mix

  • 60 multiple choice
  • 10 concept cards
  • 10 predict the output
  • 10 put it in order
  • 10 matching questions

Syllabus

What you will be asked about

  1. 01

    Return Codes vs errno

    Decide whether a failing call communicates through its return value, errno, or both, and check the right one.

  2. 02

    Checking malloc, fopen and sscanf

    Check what malloc, fopen and sscanf actually returned before trusting the result they produced.

  3. 03

    Partial Reads and Writes

    Handle a read or write call that transfers fewer bytes than requested instead of assuming it always completes.

  4. 04

    Detecting strtol Failure Properly

    Distinguish a genuine conversion failure from a valid zero or partial parse when using strtol.

  5. 05

    Off-by-One in Bounds Checks

    Write a loop or index bound that is provably correct at both ends instead of one that merely looks right.

  6. 06

    strncpy and NUL-Termination

    Predict when strncpy leaves a buffer without a terminator and write code that stays safe either way.

  7. 07

    Integer Overflow When Computing a Size

    Spot an allocation-size computation that can overflow before it reaches malloc and rewrite it safely.

  8. 08

    Cleanup Paths and goto cleanup

    Use a single goto cleanup exit to release every resource acquired so far, on every failing path.

  9. 09

    assert vs a Real Runtime Check

    Choose between assert and a real runtime check based on whether the condition can depend on untrusted input.

  10. 10

    realloc Failure and the Lost Pointer

    Rewrite a realloc call so a failed grow does not overwrite the only pointer to the original block.

8 more topics, and all 90 questions

C Errors & Edge Cases is a Pro course. One subscription opens it and every other course in the catalogue, including the ones still being written.

See pricing Find a free course

A question from this course

Return Codes vs errno

What does this print?

#include <stdio.h>
int main(void) {
    FILE *f = fopen("/no/such/directory/definitely-missing.txt", "r");
    printf("%d\n", f == NULL);
    return 0;
}
  • A1
  • B0
  • CIt does not compile: fopen needs a file that exists
  • DIt crashes trying to open a missing file
Show the answer

A 1

fopen never crashes on a missing path - it simply returns NULL, which is exactly what the return value is for. Checking f == NULL is the whole detection mechanism; nothing about opening a nonexistent file is an exception or a fatal error in C.

The rest of the track

C at every depth

FreeFoundation

C Essentials

Covers C's basic types and integer promotion, operator precedence, control flow, functions and parameters, arrays, strings as char arrays, introductory pointers, printf specifiers, scope and lifetime, and const - the syntax a beginner reaches for first. Every item runs against a real compiler, so the surprising cases are proven rather than asserted.

90 questions · 68 minutes

ProCore

C Core

Covers pointer arithmetic, arrays decaying to pointers, where const actually applies, struct assignment, malloc/free and ownership, the strcpy family, integer conversion and promotion, the ternary and comma operators, and static at file and block scope. Aimed at someone who already writes C daily but has never had the gap between what compiles and what is correct made explicit.

90 questions · 68 minutes

ProCore

C Data & Collections

Arrays decay to pointers the instant they cross a function boundary, and every container in C is really addresses and strides under a comfortable-looking syntax. This course puts pressure on that comfort: row-major layout, struct-embedded arrays, flexible array members, qsort comparators, realloc growth, and hand-built linked lists, until the mental model matches what the compiler actually does.

90 questions · 68 minutes

ProCore

C Standard Library

For a reader who reaches for a dependency before checking what the standard library already does. Works through string.h, stdio.h, stdlib.h, ctype.h, time.h, and the fixed-width types in stdint.h and limits.h, with every answer checked against what the C standard actually guarantees.

90 questions · 68 minutes

ProAdvanced

C Idioms & Pitfalls

For a reader who is fluent in C but still writes it like another language. Works through the array-length macro's function-parameter trap, const placement, designated initializers, compound literals, both meanings of static, header guards, function-pointer dispatch tables, restrict, X-macros, and the copy-semantics mistakes that leak in from Java, Python, or C++.

90 questions · 68 minutes

ProAdvancedInterview prep

C Advanced

Pointers to pointers, function pointers, unions, variadic functions, the preprocessor, recursion, setjmp/longjmp, opaque pointers and _Generic - the traps a confident C developer trips over. Every answer here is guaranteed by the standard, never by one compiler's mood on one machine.

90 questions · 68 minutes

ProAdvancedInterview prep

C Performance

Complexity you can count instead of guess: linear scans, strlen in a loop condition, memcpy versus a byte loop, realloc growth, buffered output, struct passing, static linkage, and hoisting invariant work. Every answer here is an operation count or a call count, checked by running the code - never a clock reading.

90 questions · 68 minutes

ProCore

C Testing

Ten spines on testing C the way it actually gets tested: hand-rolled CHECK macros, what NDEBUG deletes from an assert, seams built from function pointers, forcing the allocation-failure branch on purpose, and comparing floating point with a tolerance instead of ==. Every graded snippet is checked to give the same answer on every machine, and several items exist to catch a test that looks reasonable but could never actually fail.

90 questions · 68 minutes

ProAdvancedInterview prep

C Interview Questions

Ten spines of the C questions that come up when time is short: string and pointer traps, linked-list rewiring, bit tricks and const rules, each one checked to give the same answer on every machine. The items built on a premise the language does not actually guarantee - char signedness, argument evaluation order, signed overflow - explain why, instead of faking a single output.

90 questions · 68 minutes

Start C Errors & Edge Cases
in tomorrow’s session.

Enrol and this course joins your daily five, mixed in with everything else you are studying — 90 questions spread over about 18 days rather than dropped on you at once.

Browse the catalogue