Assume the following example:
uint8 myArr[4] = {0, 1, 2, 3};
uint8* ptr_a, ptr_b, ptr_c, ptr_test;
uint8** ptrptr_c;
void main(void)
{
ptr_a = &myArr[4]; // Address of myArr
ptr_b = myArr; // Address of myArr
ptr_c = &myArr; // --> Address of myArr again?! <---
ptrptr_c = &myArr; // --> Address of myArr again?! <--
ptr_test = &ptr_a // Address of ptr_a (whose content points to myArr)
}
That ptr_a and ptr_b contain the address of myArr is perfectly clear to me.
But I would've actually assumed, that ptr_c would contain some kind of address where the address of myArr is stored (analogue to ptr_test).
So, why does ptr_c (or ptrptr_c) contain the address of myArr ?
uint8* ptr_a, ptr_b, ptr_c, ptr_test;is wrong.uint8 *ptr_a, *ptr_b, *ptr_c, *ptr_test;is correct. or:typedef uint8_t* uint8_p; uint8_p ptr_a, ptr_b, ptr_c, ptr_test;. Your choice.ptr_a = &myArr[4]; // Address of myArr......absolutely not.... Most probably the address ofptr_apointer...myArr, exceptmyArritself. The array name can be seen as evaluating to the address of the first element, in most contexts (sizeofis a shining exception).ptr_a = &myArr[4]; // Address of myArr, no it is the address of&myArr[4], element which is actually out of bounds, the last element of themyArrarray beingmyArr[3].