Getting Memory
In C, malloc(
n)
returns the address of a
block of memory of size n bytes.
Pointer Variables
A pointer variable can hold an address, e.g. as returned by
malloc
. In C,
float X;
declares X
to be a variable containing a floating point
value, and
float *X
declares X
to be a variable containing the address of a
floating point value.
Invalid Address
NULL
can be stored in a pointer, but is not a valid
address. It is useful to indicate the end of a chain of pointers. Use
P=NULL;
to store it, and if (P == NULL) ...
to test it.