Translate Your Own Language

Sunday, December 16, 2018

Advantage and Disadvantage of pointer in c

advantage and disadvantage of pointer

Advantage and Disadvantage of the pointer in c

Advantage: 
  • Pointers provide direct access to memory
  • Pointers provide a way to return more than one value to the functions
  • Reduces the storage space and complexity of the program
  • Addresses of objects can be extracted using pointers
  • Pointers allow us to resize the dynamically allocated memory block.
  •  Pointers help us to build complex data structures like linked list, stack, queues, trees, graphs etc.
  • Pointers allow us to perform dynamic memory allocation and deallocation.
  • Pointers can be used to pass information back and forth between the calling function and called the function.
  • Provides an alternate way to access array elements
  • Reduces the execution time of the program
Disadvantage: 
  • Pointers are slower than normal variables.
  • Uninitialized pointers might cause the segmentation fault.
  • If pointers values updated with a wrong value, it might lead to memory corruption.
  • Crashes are common occurance in pointers.
  • Pointers syntax is really complicated.
  • Programming using pointers is really hard.
  • It is really hard to debug a program which one is create using pointers.



No comments:

Post a Comment