Pointer in C Language

Posted on

C Pointer


Pointer in C Language

 

A pointer is a variable which incorporates or maintain the deal with of one other variable. We are able to create pointer variable of any sort of variable for instance integer sort pointer is ‘int *ptr’.

In pointer following symbols are use;

Image Nme Description
& (ampersand signal) Deal with of operator Give the deal with of a variable
* (asterisk signal) Indirection operator Offers the contents of an object pointed to by a pointer.

Benefit of pointer

  • Pointer reduces the code and improves the efficiency, as a result of it direct entry the deal with of variable.
  • Utilizing pointer idea we are able to return a number of worth from any operate.
  • Utilizing pointer we are able to entry any reminiscence location from pointer.

Deal with Of Operator

The deal with of operator & provides the deal with of a variable. For show deal with of variable, we want %u.

Instance

Output


Declaring a pointer

In C language for declared pointer we are able to use * (asterisk image).

Syntax


Instance of pointer

In under picture pointer variable shops the deal with of num variable i.e. EEE3. The worth of num is 50 and deal with of pointer prt is CCC4

example pointer - Pointer in C Language

Instance

Output


NULL Pointer

A pointer that’s not assigned any worth however NULL is called NULL pointer. That is carried out on the time of variable declaration. The NULL pointer is a continuing which is outlined in customary libraries with zero worth.

Instance

Output