Write the memory contents after execution of all statements up to line 17. Write the names of each variable, its address and any data associated with them in the appropriate box.
1 extern void *lerp(void *);
2 struct tee {
3 int x;
4 void* m;
5 void *p;
6 };
7 struct tee t;
8 int main( int argc , char ** argv ) {
9 int a = 73;
10 static void *(* flerp )( void *) = lerp;
11 t.x = 51;
12 t.m = &a;
13 struct tee s = t;
14 s = *((struct tee*)(flerp((void*)&t)));
15 t.p = &s;
16 printf("%s\n", (const char *)&a);
17 // show snapshot of memory at this statement
The starting address for each segment of memory has been provided for you. For the purpose of this exam, you should assume that memory is allocated positively from 0x0000 to 0xFFFF.
sizeof(char) is 1 byte and sizeof(char *) is 4 bytes. The ASCII value of ’A’ is 65. Assume memory does not align to nearest word size.
Consider these two lines of code, the memory contents may look like −!
char a = 5;
char *b = &a;
Sample memory
0x7000 a 5
0x7001 b 0x7000
Program code
0x2000
Static/Global
0x3000
Heap
0x4000
Stack
0x7000