Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For the following program, show the initial stack, then how itchanges at each po

ID: 3608594 • Letter: F

Question

For the following program, show the initial stack, then how itchanges at each point (an excel type
matrix might be useful). Assume that there is no optimization bythe compiler so that all variables use
the exact amount of memory required. The highest memory address(bottom of the stack) is 0x0010
FF80. Put a “?” for an unknown value.

The function is called as follows: func(50, 101);

int func( int A, char B)
{
int tmpI, *pI;
char array[8];
char *pC;
// show the stack at this point, before any code executes
tmpI = 0x1000; // this is hexadecimal
pI = &tmpI;
array[0] = ‘H’; // you can show the actual character inmemory, no need for numeric values
array[1] = ‘E’;
array[2] = ‘L’;
array[3] = ‘L’;
// show the stack at this point
strcat(array, “O!”);
pC = &array[1];
*pC = B;
pC++;
// show the stack at this point
*pC = ‘Z’;
*pI = 0x1234ABCD;
pI++;
// show the stack at this point
} // end func

Explanation / Answer

Thanks but I think our teacher is asking to do it by hand by drawing out the stack in table form. I think he wants us to show the stack (with the memory locations and the stuff that is on the stack) at each of the locations that he wrote. Thats what im confused on how to do that. Thanks for your time!!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote