Pointer to Pointer

suggest change

In C, a pointer can refer to another pointer.

#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int A = 42;
  int* pA = &A;
  int** ppA = &pA;
  int*** pppA = &ppA;

  printf("%d", ***pppA); /* prints 42 */

  return EXIT_SUCCESS;
}

C has no reference type. && is lexed as a single token (the logical AND operator), so &&A is a syntax error rather than &(&A). GCC and Clang accept &&label as an extension for taking a label's address, so they may instead report an undeclared label. Even & &A with a space is a constraint violation, because unary & requires an lvalue and the result of & is not an lvalue.

#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int A = 42;
  int* pA = &A;
  int** ppA = &&A; /* Compilation error here! */
  int*** pppA = &&&A;  /* Compilation error here! */
...

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents