Kuba0040
Well-known member
Hello,
This will take some explaining, so here it goes. I have an array in memory to which I have setup a pointer to called ArrayPointer, so I can pass on the array to other functions:
Now, one function needs to get the memory address of the first cell in the array. The way I implemented this is as follows:
Here is the example function:
And here is how we pass the array to it:
test_adress_function(ArrayPointer);
However, the function shows a different address to when I just check &ArrayPointer.
Why? (I guess that LocalPointer shows the memory adress of the ArrayPointer instead of the real array). And how can I pass on the memory address of the real array in memory to a function from the ArrayPointer?
Thank You for the help.
This will take some explaining, so here it goes. I have an array in memory to which I have setup a pointer to called ArrayPointer, so I can pass on the array to other functions:
Code:
int32_t myArray[64]; //Real array in memory
int32_t *ArrayPointer=myArray; //Pointer to the array
Now, one function needs to get the memory address of the first cell in the array. The way I implemented this is as follows:
Here is the example function:
Code:
void test_adress_function(int32_t *LocalPointer)
{
Serial.printf("64bit hex: 0x%" PRIx64 "\n", &LocalPointer); //Shows the memory adress in HEX
}
And here is how we pass the array to it:
test_adress_function(ArrayPointer);
However, the function shows a different address to when I just check &ArrayPointer.
Why? (I guess that LocalPointer shows the memory adress of the ArrayPointer instead of the real array). And how can I pass on the memory address of the real array in memory to a function from the ArrayPointer?
Thank You for the help.