-1

so I recently started switching from Arduino stuff to working with microchip Studios. This is a huge step, including a lot of stuff that is hidden or simplified in the Arduino IDE. While searching for a lot of new stuff I came across Pointers. In the code I inspect it is used to give some variables values or get the value to some function etc. But in my understanding the Pointer does nothing else then Pointing to a position in the memory. So why do I even use Pointers ? If I save a value in the memory and I want to access this or rewrite the memory on this position, what is the advantage of not using the Variable itself but just a pointer wich points at this position ? can't really Get behind this so help is really appreciated.

Nic0lodeon
  • 55
  • 4
  • Pointers are mainly used for objects in the dynamic memory (i.e. heap) – Raildex May 20 '21 at 09:29
  • Does this answer your question? [What is the point of pointers?](https://stackoverflow.com/questions/850796/what-is-the-point-of-pointers) – dantechguy May 20 '21 at 09:29
  • sometimes you don't have the address at compile time so you must use pointers: [Why Use Pointers in C?](https://stackoverflow.com/q/29423757/995714), [Why use pointers?](https://stackoverflow.com/q/162941/995714). In C++ there are fewer uses for raw pointers because they're already wrapped up by std functions and smart pointers `std::shared_ptr`, `std::unique_ptr` – phuclv May 20 '21 at 09:32
  • a variable is stored in only one place, but there can be many pointers to it. – 463035818_is_not_a_number May 20 '21 at 09:45
  • 1
    `So why do I even use Pointers ?` Because we need indirection. – eerorika May 20 '21 at 13:08

0 Answers0