Skip to main content

Practice ยท 3 of 4

Grow and Preserve

A dynamic array grows by DOUBLING when full: implement int* grow(int *old, int old_cap) returning a new block of 2*old_cap ints whose first old_cap elements equal the old ones. Free nothing โ€” the CALLER still owns old. Return NULL on failure.

Difficulty: beginner

Back to lesson: Practice: Allocation Workbench