It might be worth trying a related exercise without a pointer to pointer to see why you would need it.
Suppose you want to implement this function to fill a dynamic array with n of a given value:
Code:
void fill_n(int *array, size_t n, int value);
fill_n will call malloc to allocate space for n ints, then fill with value. It could be used like this:
Code:
int *array = NULL;
fill_n(array, 10, 5);
// print the array elements
// ...
free(array);
Try to implement fill_n with the given prototype and see if you can get it to work. You will find that you need fill_n to be:
Code:
void fill_n(int **array, size_t n, int value);
instead