Question: #include #include #include int g = 100; static void func( int a) { char *s1 = abc ; char *s2 = strdup(s1); // dublicate
#include
#include
#include
int g = 100;
static void func( int a) {
char *s1 = " abc ";
char *s2 = strdup(s1); // dublicate s1 ( strdup ) duplicate string
int i1= 3;
int *i2 = &i1;
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 *s1 is at %p which is points to %p ", &s1, s1);
printf("char *s2 is at %p which is point to %p ", &s2, s2);
printf("local var i1 is at %p ", &i1);
printf("local var i2 is at %p which points to %p ", &i2, &i2);
printf( "static var i3 is at %p ", &i3);
printf("void *v1 is at %p which is point to %p ", &v1, v1);
printf("void *v2 is at %p which is point to %p ", &v2, v2);
printf("void *v3 is at %p which is point 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;
}

II. For each of the 17 addresses printed, enter one of STATIC / STACK / HEAP. 2 points each. global var g is at param a is at char *sl is at which points to char *s2 is at which points to local var it is at local var i2 is at which points to static var i3 is at void *vl is at which points to void *v2 is at which points to void *v3 is at which points to function func is at
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
