Ditto SpyrosP comments that this question is difficult to answer without going into a lengthy discussion.
My guess is that my short answer would be: Do I need pointers for programming? No. They solve some problems easier or cleaner, but you can always find alternative solutions. He likes to ask: "Are databases important for programming?" or even "Is the multiplication operator important for programming?" Take away any one or two functions, and you can almost always do the job the other way with the rest of the functions.
There are a number of examples in which pointers are useful.
For example, pointers are very useful when we want to create a relationship between two or more things, all of which can be updated independently. For example, we have a memory block with customer information and another memory block with order information. Order for some customers. We could copy all the customer information into the order block. But then, if customer information changes, we must change it in two places. What if we store several orders in memory, which may be for the same or different customers? Now, if the customer information is changed, we need to somehow find out what orders are associated with this customer, and change all of them. If we make a mistake, we may have conflicting customer information.
But with pointers, we can only have one copy of customer information, and orders have a pointer to the client. Then, if the customer information changes, we do not need to update another copy in each order, because there is no “other copy” in each order. All orders have a pointer to one copy. We change one place, and magically all other places see the same change.
You may want to get a book or find a website on data structures to get more examples.
source share