Pointers in C

A Pointer in C programming language is playing a key role. A pointer is very easy and fun to learn while learning the C programming. As you know, every variable memory location and also every location have some defined address, which can be accessed by using the ampersand (&) operator before the variable name.

What is Pointers in C

A Pointer is variable which holds the address of another variable which direct address of memory location of a variable. See the below example of pointer:

C

1

2

3

4

5

6

7

8

9

10

11

12

#include <stdio.h>

intmain(){

intabc;

charxyz[10];

printf("Address of var1 variable: %x\n",&abc);

printf("Address of var2 variable: %x\n",&xyz);

return0;

}

The output of above program is:

1

2

3

4

Address of abc variable:bff5b600

Address of xyz variable:bff5b3f6

How to define a Pointer variable in C

You can define a pointer variable by using the (*) symbol before the variable defined. See the below how to define a pointer type variable in C programming language: