Search code examples
cdouble-pointer

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?

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

Solution

  • 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.