ahmed elbarky ahmed elbarky - 4 months ago 46
C++ Question

modifying a pointer that points to another pointer

Using no other objects besides those already declared, how can
you alter ptrptr so that it points at a pointer to b without
directly touching ptr ?

int a,b;
int *ptr;

ptr =&a;


You're not allowed to touch directly ptr. So ptr = &b; is not an option.

But this doesn't prevent changing it indirectly. So *ptrptr=&b; would be the way to go.