variable types Flashcards
where is global allocation stored
in the data area of main memory
where automatic allocation stored
on the stack
where is static allocation stored
in the data area of main memory
where is dynamic allocation stored
on the heap
what is the visibility of the object in global allocation
the whole process
what is the visibility of the object in automatic allocation
within the block that it is declared
what is the visibility of the object in static allocation
within a single file or within its enclosing block
what is the visibility of the object in dynamic allocation
wherever there is a pointer/reference to it
what is the lifetime of variable in global allocation
for the execution of the process
what is the lifetime of variable in automatic allocation
while the block is executed
what is the lifetime of variable in static allocation
for the execution of the process
what is the lifetime of variable in dynamic allocation
until it is explicitly deallocated using free() method
what is the dynamic memory function which allows memory to be allocated
malloc(), the parameter within will take the size of memory which is required.
int* c = (int*)malloc(sizeof(int))
*c = b
* is a pointer to a variable whose datatype is an integer
what is the dynamic memory function which allows memory to be deallocated
free(), the parameter taken is whatever the allocation variable was saved as
in our code it was *c
when is memory available for re-use in global allocation
when the process terminates