Except a few, most of the programs in C may be written with or without pointers. Then the question arises “Why use pointers if you can do without them?” Pointers are considered to be useful tools in programming because of the following reasons:
(i) Pointers make the programs simple and reduce their length.
(ii) Pointers are helpful in allocation and de-allocation of memory during the execution of the program. Thus, pointers are the instruments of dynamic memory management.
(iii) Pointers enhance the execution speed of a program.
(iv) Pointers are helpful in traversing through arrays and character strings. The strings are also arrays of characters terminated by the null character (‘\O’).
(v) Pointers also act as references to different types of objects such as variables, arrays, functions, structures, etc. However, C language does not have the concept of references as in C++. Therefore, in C we use pointer as a reference.
(vi) Storage of strings through pointers saves memory space.
(vii) Pointers may be used to pass on arrays, strings, functions, and variables as arguments of a function.
(viii) Passing on arrays by pointers saves lot of memory because we are passing on only the address of array instead of all the elements of an array, which would mean passing on copies of all the elements and thus taking lot of memory space.
(ix) Pointers are used to construct different data structures such as linked lists, queues, stacks, etc.