Pointers in C

I’ve been brushing up on some of my programming knowledge and have re-visited an area that has always stumped me … up until now. Pointers in the C programming language. This time, I think I get it, but I’m still not sure. So that I have something to ponder on, I have summarized the conundrum here.

The unary operator & gives the address of an object, so the statement
p = &c;
assigns the address of c to the variable p, and p is said to “point to” c.

The unary operator * is the indirection or dereferencing operator; when applied to a pointer, it accesses the object the pointer points to. Suppose that x and y are integers and ip is a pointer to int. This artificial sequence shows how to declare a pointer and how to use & and *:

int x = 1, y = 2, z[10];
int *ip; /* ip is a pointer to int */

ip = &x; /* ip now points to x */
y = *ip; /* y is now 1 */
*ip = 0; /* x is now 0 */
ip = &z[0]; /* ip now points to z[0] */

The declarations of x, y, and z are what we would expect. The declaration of the pointer ip
int *ip;
is intended as a mnemonic; it says that the expression *ip is an int.

So, that’s all there is to it!

Source: Brian W Kernighan, Dennis M Ritchie; The C Programming Language; Prentice Hall Software Series, 1988