The basic way to allocate memory to your computer program in C (which is still possible to use in C++) is by using the malloc() function. This function designates a block of the computer system's memory for your program's use. Once your program is using a segment of memory, no other program can use or access that segment of memory. An attempt to access a segment of memory not allocated to your program will generate a segmentation fault, and represents an illegal operation on most systems.
Unmanaged memory – using malloc( ) / free( )
How to do it...
Let's look at some example code that allocates a pointer variable, i, then assigns memory to it using malloc(). We allocate a single integer behind an int...