Pointers
int *money
This declares money as a pointer to an integer. Since the contents of memory are
not guaranteed to be of any specific value in C, care must be taken to ensure
that the address that money points to is valid. This is why it is suggested to
initialize the pointer to NULL.
int *money = NULL;
If a NULL pointer is dereferenced then a runtime error will occur and execution
will stop likely with a segmentation fault.
Once a pointer has been declared then, perhaps, the next logical step is to
point it at something:
int a = 5;
int *money = NULL;
money = &a;
This assigns the value of money to be the address of a. For example, if a is
stored at memory location of 0x8130 then the value of money will be 0x8130
after the assignment. To dereference the pointer, an asterisk is used again:
*money = 8;
This says to take the contents of money (which is 0x8130), go to that address
in memory and set its value to 8. If a were then accessed then its value will
be 8.
--------------------------------------------------------------------------------
Taking C pointers to the next step is the array.
C has no native data type of an array (in the sense like PHP and Python have
an array and list, respectively). Arrays in C are just pointers to consecutive
areas of memory. For example, an array array can be declared in the following
manner:
int array[5];