The standard library is a header file in C that gives us gives us data types and functions for dynamic memory allocation. See this link for a full guide.
Macros
EXIT_FAILURE
: for an exit status in case of error in program termination.EXIT_SUCCESS
: counterpart to above. Equivalent to returning0
.
Functions
void *malloc(size_t num)
: allocates requested number of bytes in the heap and returns a pointer to that memory.void* calloc(size_t num, size_t sizeoftype)
: alternative tomalloc
that is debatably clearer.void *realloc(void *ptr, size_t num)
: resizes the memory block atptr
that was previously allocated; can fail if the heap has no space. Equivalent tomalloc
if first argument isNULL
.void free(void *ptr)
: de-allocates memory that was previously dynamically allocated on the heap.