Home C C++ Java Python Perl PHP SQL JavaScript Linux Online Test

Poniters in C Programming

Pointers are special type of variable which are used in storing address of some other varialble. In C programming it is allowed to create pointer to any data type. Size of pointer varies from compiler to compiler.

Pointer to Predefined Data Type


#include<stdio.h>

int main()
{
int a = 10;

int * ptr  = &a;

printf("%d",*ptr);
return 0;
}

In above program, ptr is int type pointer and it is holding address of int type variable a. If we want to get the value of variable pointed by pointer then we use * before the pointer variable.


#include<stdio.h>

int main()
{
int a = 10;

int * ptr  = &a;

*ptr++;

printf("%d",*ptr);
return 0;
}

We can increate the variable value by using pointer. Either we do a++ or *ptr++; both are doing same operations.