C Programming

DYNAMIC MEMORY ALLOCATION (CALLOC, SIZEOF, FREE)
It is desirable to dynamically allocate space for variables at runtime. It is wasteful when dealing with array type structures to allocate so much space when declared, eg,


	struct client clients[100];

This practice may lead to memory contention or programs crashing. A far better way is to allocate space to clients when needed.

The C programming language allows users to dynamically allocate and deallocate memory when required. The functions that accomplish this are calloc(), which allocates memory to a variable, sizeof, which determines how much memory a specified variable occupies, and free(), which deallocates the memory assigned to a variable back to the system.


©Copyright B Brown. 1984-1999. All rights reserved.