Pointer in C Language

Posted on

C Pointer


Pointer in C Language

 

A pointer is a variable which incorporates or maintain the tackle 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) Handle of operator Give the tackle 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 tackle 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.

Handle Of Operator

The tackle of operator & offers the tackle of a variable. For show tackle 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 beneath picture pointer variable shops the tackle of num variable i.e. EEE3. The worth of num is 50 and tackle 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 named NULL pointer. That is accomplished on the time of variable declaration. The NULL pointer is a continuing which is outlined in commonplace libraries with zero worth.

Instance

Output