Memory blocks are very useful in C programming, especially when creating dynamic arrays or when working in memory-restricted environments. If you create large user-defined complex data types, reserving array space ahead of processing time might also not be possible.
Being able to allocate, free, and reallocate memory is therefore vital in many applications. The two basic functions are malloc and free. The malloc function is defined as:
malloc ( <block size> ) // allocate a piece of memory
The function returns a void pointer, which can be cast to any type, including user-defined and complex data types. The <block size> parameter is usually a long integer, which may place a maximum block size on the memory that can be ...