Pointer

C Pointers
Pointers (pointer variables) are special variables that are used to store addresses rather than values.

Pointer Syntax
Here is how we can declare pointers.

int* p;
Here, we have declared a pointer p of int type.

You can also declare pointers in these ways.

int *p1;
int * p2;
Let's take another example of declaring pointers.

int* p1, p2;
Here, we have declared a pointer p1 and a normal variable p2.

Assigning addresses to Pointers
Let's take an example.

int* pc, c;
c = 5;
pc = &c;
Here, 5 is assigned to the c variable. And, the address of c is assigned to the pc pointer.
Posted on by