malloc(), realloc() and free() demonstration in C