Lab 3: C so far...
Quiz B - Memory Layouts
For this section you may not use any other sites such as Repl or CodeAnywhere.
Answer the questions in this Quiz using the information below.
Code Block A:
int a[2];
int b[2];
int j;
for (j=0; j <=2; j++) {
a[j] = j;
}
b[1] = 456;
Our model of the stack:
- When a function is called, space is reserved for the return value and any function arguments
- Variables are added to the stack in the order they are declared
- Addresses start at 1000 and increase with each variable added
int
andint*
variables consume 4 bytes
Code Block B:
int a = 10;
int b = 15;
int *ptr;
int **ptr2;
ptr2 = &ptr;
ptr = &a;
*ptr = 20;
*ptr2 = &b;
*ptr = 40;
Next…
You may not proceed to the next section until you submit your Quiz.
Then go here.