Pointer in C

Pointer is a variable that is used to contain the address of another variable. We can easily create a pointer in C language.

Example: int *ptr

Symbol Description
& (ampersand sign) Address of an operator is used to contain the address of a variable.
* (asterisk sign) Indirection operator is used to accesses the value at the address..

Advantage of pointer

In C language, there are various advantages of pointer that are given below:

  • It is used to reduce the code and performance.
  • It accesses the direct address of the variable.
  • It is used to return multiple values from the function.
  • It helps us to access any memory location from the pointer.

      How can we declare pointer

We can declare pointer by using * (astric symbol).

Syntax:

Let us consider an example:

Output

Null Pointer

A pointer does not assign any value that is known as a NULL pointer. We can create a null pointer at the time of declaration.

Example:

Leave a Comment