Updating pointer address in function, when passed as an argument. [ passing pointer as reference in C] -
Concept: Pointer passing by context
is trying to get: update indicator address from function To achieve, when passed as an argument.
int main (zero) {uint8_t unArray [10] = {0}; // unint8_t type unsigned four UIint8_t * pmyPtr as DIF; PmyPtr = unArray; Function (pmyPtr); * PmyPtr = someValue3; } Zero fun (uint8_t * unPtr) {* unPtr = someValue1; UnPtr ++; * UnPtr = someValue2; UnPtr ++; } Suppose we have an Aeera address as 0x0001000. Therefore pmyprtr will be 0x0001000 because it is assigned a constant indicator.
When the function function is passed then indexing of some array (the first two) is updated by DE-referenced.
When I return to main after function addition, I am trying to update the third index. How can this be achieved. I have a hip that can be easy to de-referencing.
You're right. An indicator for pointer is a simple solution. In C ++ it can be hidden in form of context.
main () {uint8_t unArray [10] = {0}; // Unint8_t type unsigned four UIint8_t * myPtr as DIF; MyPtr = AnArray; Func (& amp; myPtr); // Knowing * myPtr = someValue3; } Zero func (uint8_t ** unPtrPtr) / / one more star {uint8_t * unPtr = * unPtrPtr; // changed * unPtr = someValue1; UnPtr ++; * UnPtr = someValue2; UnPtr ++; * UnPtrPtr = unPtr; // CHANGED}
Comments
Post a Comment