0
30kviews
What is Pointer? Explain its advantages and disadvantages of it
1 Answer
1
6.5kviews

Pointer :- A pointer is a variable that stores the address of another variable. Unlike other variables that helds values of a certain type, pointer holds the address of a variables .

Advantages of Pointers are :-

  1. Pointer provide direct access to the memory.

  2. Pointer provide a way to returns more than one value to the functions.

  3. Pointers provides an alternate way to access array elements.

  4. Pointers reduces the storage space and complexity of the program.

  5. Pointer reduces the execution of the program.

Disadvantages of Pointers are :-

  1. Pointer are slower than normal variables.

  2. Uninitialized pointer might cause segmentation fault.

  3. Dynamically allocated block needs to be freed explicity. Otherwise, it would lead to memory task.

  4. If pointer bugs are updated with incorrect values, it migh lead to memory corruption.

  5. Basically, pointer bugs are difficult to handle. So, use pointer effectively and correctly.

By using * operator we can access the value of a variable through a pointer.

Please log in to add an answer.