Is it possible to change the value of let's say ***ppptr , to reflect the address of the orignal and 1st pointee, so it would point directly point to it
Thank YOU
Is it possible to change the value of let's say ***ppptr , to reflect the address of the orignal and 1st pointee, so it would point directly point to it
Thank YOU
Last edited by n@bu; 02-14-2017 at 08:48 PM.
The type would be wrong. Just create another pointer of the correct type that points to the original object.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
That is exactly the warning that I got when compiling, but I was trying to see, if I could get around it by typecasting or something like that...
I will.
Thanks a lot
It's really not very useful. And not necessarily portable. But:
Code:#include <stdio.h> int main() { int n = 42; int *pn = &n; int **ppn = &pn; int ***pppn = &ppn; pppn = (int***)*pppn; pppn = (int***)*pppn; printf("%d\n", *(int*)pppn); // but what's the point??? return 0; }
I saw some code on the Daily WTF, that was like this:
Of course, the expressions of a and "1" were more complicated, but I think the point was clear.Code:a=1; a=1; // REALLY make sure a == 1.
I know you probably just made a typo, ... I'm just joshing you. It's all good in the hood.
Last edited by MacNilly; 02-15-2017 at 01:49 AM. Reason: things
Very insightful. Thank you guys. Coming from a language where referencing/dereferencing is taken care of by the language itself. I was trying different things with pointers, to understand its powers.