calloc and realloc: dynamic memory allocation functions in C

calloc function: calloc function is used to allocate a memory of size a*b and it returns a pointer to allocated block.


void *calloc(size_t a, size_t b);

realloc function: realloc is used to change the memory allocated by a to b and it returns a pointer. The size of memory b can be anything greater or lesser than a. If size of b is greater than the overall memory then a null pointer is returned.


void *realloc(void *a, size_t b);

Leave a Reply