Could somebody please explain these lines of code as I do not understand the output on the console...
int *l = (int*)1000;
cout << l << endl;
...this prints 1000's hexidecimal equivalent to the console, why is this?
i know that when you cout << l; it gives you the address in memory that the pointer 'l' is pointing to and that when you cout << *l; it gives you the value stored at the address that the pointer is pointing to...
also when i tried
cout << *l; there was a compile error.
.this prints 1000's hexidecimal equivalent to the console, why is this?
Because that's the value of the pointer. All pointers hold a number. That is all they do. What number in this case? 1000. The number you just stored in that pointer.
Thanks for that. Read through that thread, I think I have pointers clear in my head now. I guess it was confusing me because I expected to see it's decimal value, but computers don't think like that I suppose.