Pointers are used with followings:
- Basic data type variable.
- Array Subscript variable.
- Function names.
- Structure and Union names.
Advantages of Pointers:
- Pointers are pointing to different data types and structures.
- Manipulation of data at different memory locations is easier.
- To achieve a clarity and simplicity
- More compact and efficient coding.
- To return multiple value via functions.
- Dynamic memory allocations.
Declaring a pointer variable
Pointers are declared similar to normal variables, but we must specify when we declare them what they are going to point to it. We declare a pointer to point to an integer, and then it can’t be used to point a floating-point value etc.
To declare and refer a pointer variable, provides two special operators & and *
- Address Operator (ampersand): &
- in directional Operator: *