Practice · 1 of 3
Checked Allocate
CHALLENGE
Difficulty: beginner+25 XP
Implement int* checked_alloc(int n, int *ok): allocate n ints; on success set *ok=1 and return the block; on failure (n <= 0 or malloc NULL) set *ok=0 and return NULL.
Press Submit to check your solution.
Back to lesson: Practice: Ownership Discipline