/* * memory-regions.c */ #include #include int global_variable; int main(int argc, char *argv[]) { int stack_variable; int *heap_variable; stack_variable = 12; heap_variable = malloc(sizeof(int)); printf("global variable is stored at %p\n", (void *) &global_variable); printf("stack variable is stored at %p\n", (void *) &stack_variable); printf("heap variable is stored at %p\n", (void *) &heap_variable); printf("heap_variable points to %p\n", (void *) heap_variable); printf("instructions are stored at %p\n", (void *) main); printf("printf is stored at %p\n", (void *) printf); free(heap_variable); }