The first of which is the address in memory where the string "foo" resides. The second is the address in memory where the pointer resides.
edit: I understand we're just talking terminology here. The problem is, if you're not going to call it a 'pointer', then what are you gonna call it? In my interpretation, a pointer is the type. The pointer occupies memory (32 bits on a 32-bit architecture, AFAIK0, has an address, and contains an address. The pointer points to the address it contains, which is the address of something else in memory, whatever it is.
It's not just terminology. Similarly to what I said nearby, "&a" is an address, but it doesn't have an address, now does it?
"&a" is a value, and although in some contexts it gets stuck in memory, it most certainly does not always get stuck in memory.
So since "&a" is a pointer, it follows that pointers do not always occupy memory.
You and others are thinking of the instances where there is a variable of type pointer-to-something. But pointers exist even in the absence of such variables, you see.
View all comments
Show parent comment
6
u/[deleted] Jul 23 '08 edited Jul 24 '08
Yeah. Pointers don't require storage! They're Magic!
A pointer has an address:
Prints:
The first of which is the address in memory where the string "foo" resides. The second is the address in memory where the pointer resides.
edit: I understand we're just talking terminology here. The problem is, if you're not going to call it a 'pointer', then what are you gonna call it? In my interpretation, a pointer is the type. The pointer occupies memory (32 bits on a 32-bit architecture, AFAIK0, has an address, and contains an address. The pointer points to the address it contains, which is the address of something else in memory, whatever it is.