Initialization of the pointer variable
When two pointers are referencing with one variable, both pointers contain the address of the same variable, and the value changed through with one pointer will reflect to both of them.
To access the pointer variable: If the ‘*’ (asterisk sign) is before the pointer variable this means the pointer variable is now pointing to the value at the location instead of pointing to the location.
Example:
C program to find reverses of a number
#inlcude<stdio.h>
#include<conio.h>
void main()
{
int n,a;
int *rev, *rem, *temp;
printf(“Enter any number”);
scanf(“%d”,&n);
a=n;
temp=&n;
*rev=0;
/* place values of digits from n are reversed by cumulative multiplication by 10
Starting from the least significant digit to the most */
while(*temp>0)
{
*rem = *temp%10;
*temp = *temp/10;
*rev =(*rev)*10 + *rem;
}
printf(“Reverse of %d”is %d”, a, *rev);
}
OUTPUT
Enter any number: 123
Reverse of 123 is 321