Practice ยท 1 of 3
Checked Allocate
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.
Difficulty: beginner
Press Submit to check your solution.
Back to lesson: Practice: Ownership Discipline