Advantages and Disadvantages of pointers in C language
By this time, you might have understood the concepts of C pointers and if any problem is given, you should be in a position to solve. After understanding the full concepts of pointers, we should be in a position to answer the question " What are the advantages and disadvantages of pointers?"
- More than one value can be returned using pointer concept (pass by reference).
- Very compact code can be written using pointers.
- Data accessing is much faster when compared to arrays.
- Using pointers, we can access byte or word locations and the CPU register directly. The pointers in C are mainly useful in processing of non-primitive data structures such as arrays, linked list etc.
- Un-initialized pointers or pointers containing invalid addresses can cause system crash.
- They are likely to be used incorrectly causing bugs that are very difficult to identify and rectify.
- They are confusing and difficult to understand in the beginning and if they are misused the result is unpredictable.