Pointers


Pointers are variables that store the addresses of other variables. In other words, pointer points to a variable that is stored at a given address. Typically, pointers occupy 4 bytes of memory. In C language it is possible to declare the type of the variable that the pointer indicates.
Example:
int* pointer is a pointer that points to the variable which is an integer.
char* pointer is a pointer that points to the variable which is a char etc.

There are a few operations on pointers available:

1. Assigning the address to a given pointer.
int *p1;

int *p2;

int a=50;

int b=40;

p1 = &a;

Pointer p1 has the address of the variable 'a' assigned.

2. Assigning pointer to a pointer.
p2=p1;

3.Assigning to a variable the value pointed at the address indicated by the pointer.
a=*p1;
Now, the variable b has a value from the address pointed to by p1.