ABSTRACT

The C language provides us with two techniques to allocate memory: static and dynamic. The former allocates a fixed amount of memory, and during the execution of our programs, we may or may not use the entire allocations. The latter gives us the flexibility to allocate memory at run time. We can allocate memory with dynamic memory allocation as and when required and hence avoid memory wastage. Several predefined functions are available for this purpose, like malloc, calloc, realloc, and free. This chapter starts with a discussion on how memory allocation occurs and later describes memory allocation types. Finally, the chapter explains the syntax of all predefined functions and their uses.