You mean you want to make the array bigger and add more items? Use realloc()
Originally Posted by Alexander
But of course in real code (not just an example) you'd want to save the result of realloc() to a temporary pointer first and check if it's NULL, otherwise you could have a memory leak if you overwrite your pointer with NULL without freeing it first.
int* pNums = malloc( sizeof(int) ); /* An array of 1 int. */
pNums = 5;
pNums = realloc( pNums, 3 * sizeof(int) ); /* Now it can hold 3 ints. */
pNums = 10;
pNums = 666;