By considering that the memory is divided into four segments: data, heap, stack, and code, where do global variables, static variables, constant data types, local variables (defined and declared in functions), variables (in main function), pointers, and dynamically allocated space (using malloc and calloc) get stored in memory?
I think they would be allocated as follows:
char *arr
, int *arr
) -------> heapI am referring to these variables only from the C perspective.
Please correct me if I am wrong as I am new to C.
You got some of these right, but whoever wrote the questions tricked you on at least one question:
main
function -----> char *arr
, int *arr
) -------> static
pointer, in which case the pointer itself would end up in the data segment.malloc
, calloc
, realloc
) --------> It is worth mentioning that "stack" is officially called "automatic storage class".