Hi
@yungman, let's try this.
In your Notes you have: *Page 496: Pointer variable:
int* ptr;
Which is fine.
A point that has not been mentioned is that internally the C compiler keeps track of what kind of object is being pointed to. Here is the reason.
If you write x= &ptr + y, the compiler has to know whether the variables are Integers, Floats, Longs, and so on. That way it can call the correct Add routine, or maybe first call a conversion if the types are not all the same.
In the
int* ptr; you are declaring a variable called
ptr, telling the compiler to treat it as a Pointer to something by using the
*, then telling it that it is pointing to a variable that is an Integer.
When
ptr is entered into the compilers symbol table for later use, it has attached to it the information that it is a Pointer, and that it refers to an Integer. So yes, PART of the information saved in
ptr is an address (these days it looks like an unsigned integer, or maybe an unsigned long), but it also contains that "Hey, it's an Integer There" information. So referring to
ptr returns all of this, not just the address (which may look like an integer).
(A rather lame equivalent, like reading a mystery novel where all the players and suspects are not introduced!)
Hope this helps!
Cheers,
Tom