The following code is subject to the MIT license.
If the program is out of control and you are in trouble, press <Ctrl-C> to stop it.
Dynamically allocate an array of pointers
/*
For the sake of brevity, error handling
has been omitted from the following code.
Please see the remarks below for more information.
*/

# include <stdlib.h>
// to call fn. malloc and fn. free

char **p;
char *b;
int i;

p = (char**) malloc(n*sizeof(*p));
// allocate bytes for n pointers

i = 0;
while(i<n) {
b = (char*) malloc(m*sizeof(**p));
// allocate m bytes
*(p+i) = b;
// on each pointer
i++;
}

// Remarks:
// Remember to call the free() function
// to release the memory buffer allocated by the malloc() function
// before terminating the program.