Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Declare Double Pointer From Normal Variable On Single Line

How can I declare a double pointer and assign its value directly from a normal variable?
Thanks

int a = 5;
int* b = &a;
int** c = &b;
int** d = &&a;//This does not work
int** e = &(&a);//This does not work

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How can I declare a double pointer and assign its value directly from
a normal variable

You cannot. "double pointer" is not a special construct in C. It is a short name for a pointer-to-pointer. A pointer always points to a variable, i.e., something with a memory location. &a is an "rvalue", not a variable. It has no memory location and, therefore, you cannot point to it.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading