What is static memory allocation and dynamic memory allocation?

What is static memory allocation and dynamic memory allocation?

Static Memory Allocation: Memory is allocated for the declared variable by the compiler. The address can be obtained by using ‘address of’ operator and can be assigned to a pointer. The memory is allocated during compile time. Since most of the declared variables have static memory, this kind of assigning the address of a variable to a pointer is known as static memory allocation.

Dynamic Memory Allocation: Allocation of memory at the time of execution (run time) is known as dynamic memory allocation. The functions calloc() and malloc() support allocating of dynamic memory. Dynamic allocation of memory space is done by using these functions when value is returned by functions and assigned to pointer variables.
Purpose of main() function
The function main() calls / invokes other functions within it. The execution of the program always starts with main() function.....
What is the difference between #define and constant in C?
A #define is used as immediate constant or as a macro. Where as the constant is a variable whose value can not change.....
What are storage class in c?
The scope and lifetime of a variable or / and function within a C program is defined by storage class.....
Post your comment