Question: For the C code below, I need to know which of the addresses are stack, static, or heap addresses. I've labeled them according to what

For the C code below, I need to know which of the addresses are stack, static, or heap addresses.

For the C code below, I need to know which of the

I've labeled them according to what I THINK they are, but I'm not sure.

addresses are stack, static, or heap addresses. I've labeled them according to

#include #include #include int g = 100; static void func(int a) { char *s1 = "abc"; char *s2 = strdup (S1); int il = 3; int *i2 = &il; static int i3 = 300; void *v1 = malloc(10); void *v2 = (void *) "abcdef"; void *v3 = (void *) &i1; printf("param a is at %p ", &a); printf("char *51 is at %p which points to %p ", &s1, s1); printf("char *s2 is at %p which points to %p ", &s2, s2); printf("local var il is at %p ", &i1); printf("local var i2 is at %p which points to %p ", &ii, i2); printf("static var i3 is at %p ", &i3); printf("void *v1 is at %p which points to %p ", &v1, v1); printf("void *v2 is at %p which points to %p ", &v2, v2); printf("void *v3 is at %p which points to %p ", &v3, v3); } int main(int argc, char *argv[]) { printf("global var g is at %p ", &g); func(4); printf("function func is at %p ", &func); return 0; } global var g is at Ox601050 (STATIC) param a is at Ox7fff4ec726fc (STACK) char *s1 is at Ox7fff4ec72710 (STACK) which points to 0x4007d8 (HEAP) char *s2 is at Ox7fff4ec72718 (STACK) which points to 0x1fdc010 (HEAD) local var il is at Ox7fff4ec7270c (STACK) local var i2 is at Ox7fff4ec7270c (STACK) which points to Ox7fff4ec7270c (STACK) static var i3 is at Ox601054 (STATIC) void *vl is at Ox7fff4ec72720 (STACK)_which points to Oxlfdc030 (HEAP) void *v2 is at Ox7fff4ec72728 (STACK)_which points to Ox4007dc (HEAP) void *v3 is at Ox7fff4ec72730 (STACK) which points to Ox7fff4ec7270C (STACK) function func is at Ox4005cd (STATIC)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!