pointers
A pointer is memory address.
On most modern 32-bit computers, a pointer is implemented as a 32-bit integer.
Pointers are very fundamental to C
the only way a routine can modify something passed as an argument.
declaring a pointer
type *name;
pointer arithmetic
int myInts[10]; *myInts = 3; /* these two are equivalent */ myInts[0] = 3; *(myInts + 2) = 5; /* these two are equivalent */ myInts[2] = 5;
constness
To indicate to the user of your function whether or not the function
will alter the data pointed to by an argument, use the
const
modifier.
function pointers
uses:
- algorithm with replaceable functionality
- list of actions
- data with attached function (a method)
Define a type for certain type of function
typedef (return_type)function_type_name( arg1_type arg1 name ...)
other loops
Rather than thinking of just looping over arrays, one can do many other kinds of traversals of other structures
Example: printing linked list