Skip to main content

Practice ยท 2 of 4

Return a Pointer via `T **`

Implement the out-parameter pair: ``c /* allocates n+1 bytes, copies s, NUL-terminates; sets *out. Returns 1 on success, 0 on any failure (NULL args, malloc fail). */ int str_dup(const char *s, char **out); /* frees *out and sets *out to NULL (so double-free becomes a no-op); returns 1 if there was something to free, 0 otherwise. */ int str_release(char **out); ``

Difficulty: intermediate

Back to lesson: Practice: Two-Level Indirection Gym