Pointers are special variables which store address of some other variables.
Syntax: datatype *ptr;
Here * indicates that ptr is a pointer variable which represents value stored at a particular address.
Example: int *p;
‘p’ is a pointer variable pointing to address location where an integer type is stored.
- Pointers allow us to pass values to functions using call by reference. This is useful when large
sized arrays are passed as arguments to functions. A function can return more than one value by using call by reference.
Dynamic allocation of memory is possible with the help of pointers.
We can resize data structures. For instance, if an array’s memory is fixed, it cannot be resized.
But in case of an array whose memory is created out of malloc can be resized.
- Pointers point to physical memory and allow quicker access to data.