Merits and demerits of using pointer over array and explain
Answers
Answered by
8
Answer:
Merits:
1. First of all pointers allow dynamic memory allocation
2. It allows the implementation of sharing just by passing the address of the variable.
3. In case of Array it has the limitations of fixed size which will be a problem while implementing the complex data structures like Linked List, trees, Stack,Queue etc. Pointers overcome the limitations
Demerits:
1. It allocates the blocks dynamically which need to be freed explicitly otherwise message leaking can be happened.
2. Pointers are slower than normal variables.
3. If pointers are not initualized properly it can be a reason of segmentation fault.
Similar questions
Economy,
6 months ago
Science,
6 months ago
Biology,
6 months ago
History,
1 year ago
Political Science,
1 year ago