// Example 1int *pa;
int *pb; // pa and pb are pointers to int variablesfloat *fx;
float *fy; // fx and fy are pointers to float variables// Example 2int a = 2;
int *b; // uninitialized pointer - may contain unexpected addressint *c = &a; // address of variable a is assigned to pointer cint d = *c; // value at address c is assigned to d (d = 2)// define a new pointer e that points to the same memory as cint *e = c;
float f = 3.0f;
float *fp = &f; // okint *a = &f; // problem: a is of type int* but points to float// Example 3int a = 2;
int *b = &a; // pointer b points to aint **c = &b; // double pointer c points to b// c now holds the address of b, which holds the address of aint *d = *c; // contents of b (address of a) is assigned to dint e = *(*c); // contents of a (2) is assigned to e