1)Through pointer we can access the address of a variable in other words through pointer we are indirectly accessing variable.
Ex:
#include<stdio.h>
main()
{
int a = 10;
int *p;
p = &a;
printf("*p = %d\n",*p) \\it should print p = 10,as p is pointing to a;
*p = 20; \\ indirectly accessing the variable;
printf("*p = %d \n a = %d \n",*p,a); \\ It should print *p = 20 & a = 20; as we have changed the value indirectly;
}
2) Another use of a pointer is when we want to pass the address of the function then in function (formal argument) it should be used by pointer.
ex:
#include<stdio.h>
void swap(int *,int *);
main()
{
int a = 20,b = 30;
printf("before swapping value is ,a=%d & b=%d\n",a,b); \\it will print a=20,b=30;
swap(&a,&b);
printf("after swapping value is ,a=%d & b=%d\n",a,b); \\it will print a=30,b=20;
}
void swap(int *p,int *q)
{
int temp;
temp = *p;
*p = *q;
*q = temp;
}
Still there are many more uses of pointer,
i hope i have cleared your doubt