Doesn't it technically also contain its own address? So it contains the address of another variable and the address of itself. Pointers are hard...
Doesn't it technically also contain its own address? So it contains the address of another variable and the address of itself. Pointers are hard...
You can "get" the address of a variable (or more generally, of any l-value) with the & operator. That operator is nothing else but an "escape" character that says "Dear C, I don't want you to load the current value of that variable. Give me just the address where it lives so I can load it later".
(Same applies to storing instead of loading)
Huh? Then you probably don't understand the meaning of "contains" here. Or what variables are in general. Variables are hard...
All our bytes of ram are numbered. We read a value from byte number 8 and that value is 17.
"Byte number 8" is a pain to remember or calculate so we give it a label and let the computer keep track. That's a "variable".
What does that 17 mean though? Is it a value we want to use later on? It might be. Or it could be referring to Byte 17 in our ram. Byte 17 happens to have the value 42 so if we use Byte 8 as a pointer that's the value we end up with.
But it's entirely our choice. It's just a number and we can treat it as a value or a pointer to another memory address as we like.