how a pointer variable declared in c why is it


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''.

 

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: how a pointer variable declared in c why is it
Reference No:- TGS0305522

Expected delivery within 24 Hours