Hi guys I'm having problem understand this block of code...Can someone help?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
void myFunction (int* myPtr)
{
int* x = myPtr + 1;
x[2] = 10;
myPtr = newint[5];
for (int i = 0; i < 5; ++i)
myPtr[i] = x[0] + i + 3;
}
int main()
{
int* data = newint[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;
}
SO what I dont understand is that why there is an array namned "x"; the previous code had an array called data that pass into the function.. But will it pass on all the elements in data array so x will be pointing to the same array or x is just pointing to a single value in data? Hope someone can shed some light on this.. Thx!