Pointers?

Aug 21, 2009 at 3:44am
We all know a pointer's main function is to hold the address of another variable. But a thought that just came into my mind: does a pointer variable have its own address within the memory or no?
Aug 21, 2009 at 4:17am
Yes.
1
2
3
4
5
6
7
8
9
10
#include <iostream>

int main(){
    int a=0;
    int *b=&a;
    std::cout <<*b<<std::endl
        <<b<<std::endl
        <<&b<<std::endl;
    return 0;
}
Aug 21, 2009 at 6:24am
sure, you can even have a pointer who refers to another pointer. And the another pointers refers to the adress of the first pointer
Last edited on Aug 25, 2009 at 6:34am
Aug 21, 2009 at 10:08am
You can have 3 levels of pointing I think. I had a pointer to an array (which is a pointer) of C strings (which are pointers).
Aug 21, 2009 at 10:35am
Chris : I don't think there is a (that low) limit for pointer-pointers.
Aug 21, 2009 at 11:59am
Of course it does. Pointers are variables, and all variables have an address in the RAM.
Aug 21, 2009 at 1:02pm
... except those optimised into registers.
Topic archived. No new replies allowed.