Question
Memory Diagram - Draw a memory diagram for the following block of code. [10 points] void myFunction(int * myPtr) { int* x = myPtr +
Memory Diagram - Draw a memory diagram for the following block of code. [10 points]
void myFunction(int * myPtr)
{
int* x = myPtr + 1;
x[2] = 10;
myPtr = new int[5];
for (int i = 0; i < 5; ++i)
myPtr[i] = x[0] + i + 3;
//Draw state of memory here.
}
int main ()
{
int* data = new int[6];
data[0] = -2;
for (int i = 1; i < 6; i++)
data[i] = *(data + i - 1) + 2;
*data = 10;
int* temp = data;
myFunction(data);
return 0;
}
(You can use Google Draw or some other application to generate a nice-looking diagram. Copy and paste your memory diagram here)
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