#include <stdio.h>
int main () {
char *ptr;
ptr = (char *) malloc(10);
strcpy(ptr, "Programming");
printf(" %s, address = %u\n", ptr, ptr);
ptr = (char *) realloc(ptr, 20); // Reallocate 20 characters of memory space
strcat(ptr, " In 'C'");
printf(" %s, new address = %u\n", ptr, ptr);
free(ptr);
return 0;
}Source:wwruttual.wi.com