What is a pointer? What are the operations that can be performed on a pointer? Also, point out the uses of a pointer.

The pointer is a variable which stores the address of another variable for eg. an integer pointer stores the address of integer variable.
                       int *x, y;
This means a gets the address of b. 
The pointer should be of the same type as the data-type of the variable whose address it is to store.

Different operations possible on pointer variables are:
  • Addition of an integer to a pointer
  • Subtraction of an integer from a pointer
  • Subtraction of two pointers
  • Comparison of two pointers

Uses of pointer variables:
  • Pointers help in performing dynamic allocation/ de-allocation of memory-blocks.
  • They allow the changed values of function arguments to be accessible in the calling function.
  • They allow the  passing of an array into a function as a function argument.
  • Pointers provide efficiency.
  • The pointer notation is also used to access array elements.

Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:


Mukesh Rajput