Home › C Tutorial › C pointers
C pointers
Variables that hold addresses.
Declare with *. p = &x stores an address; *p reads or changes the value there (dereference). Arrays decay to pointers.
Example code
#include <stdio.h>
int main() {
int x = 5, *p = &x;
*p = 9;
printf("%d %d\n", x, *p);
int a[] = {1, 2, 3};
printf("%d\n", *(a + 2));
return 0;
}