Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Study the following program and answer the questions: #include #include int uig; int ig - 5; int func) return 0; int main0 int local; int
Study the following program and answer the questions: #include #include int uig; int ig - 5; int func) return 0; int main0 int local; int *ptr; ptr - (int *) malloc(sizeof(int)); printf("An address from BSS: %p ", &uig); printf("An address from Data segment: %p ", &ig); printf("An address from Code segment: %p ", &func); printf("An address from Stack segment: %p ", &local); printf("An address from Heap: %p ", ptr); printf("Another address from Stack: %p ", &ptr); free(ptr); return 0; Questions: Examine last line of output. It shows another address from stack. 1. Why &ptr is in the stack segment? 2. Why distance is 4 byte between local and &ptr? 3. Why &ptr is less than &local
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started