Why would you want a pointer referencing to another pointer?

If you're not sure what I'm talking about, check out Md Sharique 's answer in this post: https://www.sololearn.com/Discuss/1799281/?ref=app In what case would you actually use a pointer referencing another pointer?

5/20/2019 11:22:02 AM


11 Answers

New Answer


that is the basic concepts about pointers, there is nothing much you can do with just using those. when you're advanced enough, you'll see how useful it is after you head down to the realm of data structures and their memory management techniques with linked lists, trees, and graphs. it's uses is critical in making dynamic memory allocation in C and C++, and gives you a good concept of how computers store and manage their memory. pointers are really beautiful once you understand how to use them.


Lists that point to other lists perhaps?


Actually i have never done any practical based on it.. may be it would help in coding very complex logics..


you can use it when you decide to use pointer to access a multidimensional array


It is useful for 2D arrays for example. Another use can be changing a variable via 2 levels of functions. e.g. https://code.sololearn.com/c36xSDug9Ju1/?ref=app


In order to know address of first pointer It used when we create chain of linking nodes


my understanding of using pointers is very limited but I would think they'll be used when data is stored in a more complex way than usual, like lists pointing to lists oder some multidimensional array stuff. (sry my English is not the best)


Pointers is an alternative way to use when you want to use variables via methods and functions especially in C. Think of it like this. When you want a value from a function or a method , you can call the adress of this value, the memory location from the value. In my perspective is easier that way. There are alot of tutorials and analysis if you just search for C pointers in the web. PS : i liked very much the course C here in sololearn, althought it didnt include the method of pointers. It is such a pity!!!


I found the best answer to this question here https://stackoverflow.com/questions/5580761/why-use-double-pointer-or-why-use-pointers-to-pointers?newreg=afe32c63c91a4fddadb426beeb261891


Suppose the first 15 addresses on the stack are related, you could use double indirection to store the last address on the second one. This would be better memory management I guess 🤔. Data would be stored on the heap as usual ...


Pointer is a variable which is used to store the address of the simple variable of the same datatype. E.g. Int a,*p; p=&a; /*p is a pointer which is variable used to store the address of a */ But pointer to pointer is variable used to store the address of other pointer variable same datatype. E.g. Int a,*p,**b; p=&a; b=&p; /*b is pointer to pointer variable used to store the address of pointer p */