The Essence of Pointers
For some, working with pointers can be confusing; however,
there are only a few things to remember about using pointers:
-
How to declare one:
int * ip;
-
How to create one:
ip = &x;
-
How to access one:
*ip = 5;
x = *ip + 3;
What will this do?
*ip = x + *ip;
Things to remember:
-
The & (address of operator) creates a pointer.
-
The * (dereference operator) follows a pointer.
-
An <Lvalue> can now be either:
- a variable name, x (for direct access)
- a dereferenced pointer, *ip (for indirect access)
-
The value of a pointer variable IS an arrow.
to Overview.