2. Pointer
Pointer : Pointer is a variable that stores the address of another
variable.
Features of Pointers :
• Pointer saves the memory space.
• Execution time with pointer is faster because data is manipulated
with the address i.e. direct access to memory location.
• The memory is accessed efficiently with the pointer i.e. dynamically
memory is allocated and deallocated.
4. Accessing a variable through its pointer :
To access the value of the variable, indirection operator (*) is used.
eg :
*int qty = 175, *p,n;
p = &qty;
n = *p;
‘*’ can be treated as value at address
The 2 statements are equivalent to the following statement
p = &qty;
n = *p; n =qty
5. POINTER TO POINTER
Pointer to pointer is a variable that holds the address of another
pointer
Declaration
datatype ** pointer_name;
Eg : int **p; p is a pointer to pointer
6. Initialization:
• ‘&’ is used for initialization.
Eg:
int a = 10;
int *p;
int **q;
p = &a;
q =&p;
Accessing:
Indirectional operator(*) is used for accessing.
7. Program
#include<stdio.h>
int main ( )
{
int a = 10;
int *p;
int **q;
p = &a;
q = &p;
printf("a =%d” ,a);
printf("na value through pointer = %d", *p);
printf("na value through pointer to pointer = %d", **q);
}