Explain declaration of pointer variable ewith example

How to declare pointer variable explain with example

Declaration

In C every variable must be declared by its type. Since pointer variables contain addresses that belong to a separate type, they must be declared as pointers before we use them.
The declaration of a pointer variable takes the following form :
data_type *pt_name;
This tells the compiler three things about the variable pt_name :
The asterisk ( * ) tells that the variable pt_name is a pointer variable.
pt_name needs a memory location.
pt_name points to a variable of type data type.

For example :


                       int *p;

Declares the variable p as a pointer variable that points to an integer data type.

Here int is the data type of the variable being pointed to by p and not the type of the value of the pointer.


Labels: