Programming in C: Unit III (b): Pointers

Memory Allocation in C Programs

Static allocation When we declare a static or global variable, static allocation is done for the variable.

MEMORY ALLOCATION IN C PROGRAMS

C supports three kinds of memory allocation through the variables in C programs:

Static allocation When we declare a static or global variable, static allocation is done for the variable. Each static or global variable is allocated a fixed size of memory space. The number of bytes reserved for the variable cannot change during execution of the program. Till now we have been using this technique to define variables, arrays, and pointers.

Automatic allocation When we declare an automatic variable, such as a function argument or a local variable, automatic memory allocation is done. The space for an automatic variable is allocated when the compound statement containing the declaration is entered, and is freed when it exits from a compound statement.

Dynamic allocation A third important kind of memory allocation is known as dynamic allocation. In the following sections we will read about dynamic memory allocation using pointers.

Programming in C: Unit III (b): Pointers : Tag: : - Memory Allocation in C Programs