Pointer Operator in C Program
Pointer Operator in C Program
In the previous chapter we have learnt about finding the size of pointer variable. In this chapter
we will be learning about different pointer operators in C Programming language.
In order to create pointer to a variable we use “*” operator and to find the address of variable we
use “&” operator.
[box]Don’t Consider “&” and “*” operator as Logical AND and Multiplication Operator in Case of
Pointer.[/box]
Important Notes :
#include<stdio.h>
int main()
{
int n = 20;
printf("\nThe address of n is %u",&n);
printf("\nThe Value of n is %d",n);
printf("\nThe Value of n is %d",*(&n));
}
Output:
m = &n Address of n is stored in m , but remember that m is not ordinary variable like ‘n’
So Ccompiler must provide space for it in memory.Below is Step by Step Calculation to compute
the value –
m = * ( &n )
= * ( Address of Variable 'n')
= * ( 1000 )
= Value at Address 1000
= 20
int *ptr;
1. ‘ptr’ is declared as that ‘ptr’ will be used only for storing the address of the integer valued
variables
4. Declaration Memory
Explanation
Required