Pointers and Arrays


char *cp;
char buffer[100];
char c;

....c = search_character();
....cp = buffer;
....while (*cp != c) ++cp;


struct bigstruct A[20];
struct bigstruct *bsp;

....for (bsp=A, k=0; k<n; ++bsp, ++k) {
........total += bsp->amount;
........}

Arrays are pointers.

buffer is really of type char *, and it points to the first character of a
block of 100 characters.

A points to the first element in a block of 20 bigstructs.

++bsp increments the pointer bsp by one unit --- here the unit is the

number of bytes in a bigstruct.

Arithmetic on pointers is done in the relevant units --- the size of the object
....being pointed to.