What is a pointer?

A pointer is essentially a simple integer variable that contains a memory address that points to a value instead of maintaining the actual value itself. The computer memory is a sequential storage of data and a pointer points to a specific part of the memory.

Pointers in C

Pointers in the C language is a variable that stores / points the address of another variable. A C pointer is used to allocate memory dynamically, that is, at run time. The pointer variable can belong to any of the data types, such as int, float, char, double, short, etc.

Syntax of the pointer:

data_type * var_name;


int * p; *,


where * is used to denote that “p” is a pointer variable and not a normal variable.

Become a C and C++ Certified Expert in 25Hours

Key Points To Remember About Pointers In C:

  • The normal variable stores the value, while the variable of the pointer stores the address of the variable.
  • The content of pointer C is always an integer, that is, the address. Always the pointer C is initialized as null, that is, int * p = null. The value of the null pointer is 0. and the symbol is used to obtain the address of the variable.
  • the symbol is used to obtain the value of the variable to which the pointer is pointing. If a pointer in C is assigned to NULL, it means that it is pointing to nothing.
  • the addition of pointer, multiplication, division is not allowed. The size of any pointer is 2 bytes (for the 16-bit compiler).

Types of a pointer in C

Null pointer

We can create a null pointer by assigning null value during the declaration of the pointer. This method is useful when you have no assigned address to the pointer. A null pointer always contains the value 0.

Void Pointer

In programming C, an empty pointer is also called as a generic pointer. It does not have any predetermined data type. An empty pointer is created using the keyword void

Wild pointer

A pointer is said to be a wild pointer if it is not initialized at all. Always be careful when working with wild pointers.

Advantage of the pointer in C

  • The pointer reduces the code and improves performance, it is used to recover chains, trees, etc. and it is used with matrices, structures, and functions.
  • We can return several values of a function using the pointer.
  • You can access any memory location in the computer’s memory.

Get C and C++ Training with Real Time Project