Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Regarding pointers, If a pointer has a pointer which uses a double astrik. Why don't pointers take an infinite number of space on the computer?

Why does the double pointer’s address not take space in the form of another pointer? Why wouldn’t this continue endlessly if each stored integer had an address and each address had another address?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

A pointer to a pointer (T **) is still just a pointer. As such, it will consume just as much memory, as any other pointer would.

Now, let’s assume this scenario.

int someVariable = 0;
int *pSomeVariable = &someVariable;
int **ppSomeVariable = &pSomeVariable;

You could, in fact, keep going like this until your mind explodes.
Each of these variables consumes a total of 4 bytes on a 32 bit system, int because it is an int and the int * and the int **, because pointers are 32bit wide on 32bit systems (hence the name).

The content of these variables however are nothing but values. You can make them point to anything, but the variable itself will never consume more than those 4 (or 8 on 64bit systems) bytes.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading