DEV Community

Tomislav Kraljic
Tomislav Kraljic

Posted on • Updated on

Why Use Pointers in C?

#c

Here, I will outline the importance of pointers and why we should use them when building programs in C.

What is a Pointer?

  • A pointer is a special variable where the value if a memory address.

Reasons to Use Pointers

  1. Accessing data by only variables is very limiting and expensive. With pointers, you can access any location and perform arithmetic operations with pointers.
  2. Pointers make it easy to use arrays and strings.
  3. Pointers allow you to refer to the same memory space from multiple locations. This means that you can update memory in one location and you will see the change everywhere else it is being used in the program.
  4. Saves space by being able to share components in your data structures.
  5. Pointers allow functions to modify data passed to them as variables.
  6. Pointers allow us to get multiple values from a function.
  7. Dynamic memory can be allocated according to the program use. We can save memory from static declarations.
  8. Pointers allow us to develop complex data structures like queues, linked lists and stacks.
  9. Pointers provide direct memory access. This makes our program run very fast and efficient!

Top comments (0)