dynamic memory allocation in c , free some part of memory that is allocated before using malloc()
问题 Is there any way to free some part of memory you created by using malloc(); suppose:- int *temp; temp = ( int *) malloc ( 10 * sizeof(int)); free(temp); free() will release all 20 byte of memory but suppose i only need 10 bytes. Can i free last 10 bytes. 回答1: You should use the standard library function realloc . As the name suggests, it reallocates a block of memory. Its prototype is (contained in the header stdlib.h ) void *realloc(void *ptr, size_t size); The function changes the size of