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 :
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.