Skip to main content

Practice · 3 of 4

Contract or Error Path?

CHALLENGE
Difficulty: advanced+25 XP

Implement const char *classify_condition(int kind) mapping: 0 (NULL from malloc) → "error-handling", 1 (user typed negative size) → "error-handling", 2 (internal: node->next == node in an acyclic list) → "assert", 3 (file open failure) → "error-handling", 4 (internal: popped an empty stack the API forbids) → "assert". The rule: caller-controllable or environmental → handle; contract-impossible → assert.

Back to lesson: Practice: Forensics Drills