When you want to call the free function,you should use the argument as
which is returned by the previous call of the malloc.Otherwise it would display the error like invalid pointer in free(). If you already called the free(), again tried to call the free() with same pointer variable behavior is undefined.