How a pointer variable declared in C ? Why is it sometimes desirable to pass a pointer to a function as an argument?
A pointer is a variable which contains the address in memory of another variable. We can have a pointer to any variable type.
To declare a pointer to a variable do:
int *ip;
This declaration looks like our earlier declarations, with one obvious difference: that asterisk. The asterisk means that ip, the variable we're declaring, is not of type int, but rather of type pointer-to-int. (Another way of looking at it is that *ip, which as we'll see is the value pointed to by ip, will be an int.)
The unary or monadic operator & gives the ''address of a variable''.
The indirection or dereference operator * gives the ''contents of an object pointed to by a pointer''.