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;
}
III. Each of the following are worth 2 points each. What is lowest STATIC address? highest STATIC address? What is lowest STACK address? highest STACK address? What is lowest HEAP address? highest HEAP address? Is there any overlap between HEAP and STACK addresses (Yes or No)? Is there any overlap between STACK and STATIC addresses (Yes or No)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