February 18th, 2012, 04:55 AM
[RESOLVED] Simple question - mem addresses
Hello everyone - just registered and thought someone might be able to explain something to me.
I'm back in school which I should have ten years ago but I'm finishing what I didn't. Fun so far.
In the 2nd quarter of programming and we are learning c++. 1st quarter was a breeze. 2nd quarter has killed me getting in to pointers, templates, exception handling (that was easy), classes, etc. The more powerful tools of the language.
Right now I am screwing around to teach myself the next weeks readings. Linked lists.
I'll get it but here is what I am questioning.
If you look at the attached code I thought if I made head a pointer, made current a pointer, both pointing to the same stucture that when I checked the memory address, they would both be the same but they are not.
Now maybe I have been up to late and not doing something right (obviously I am not).
address of head is 0x28ff44
address of current is 0x28ff40
(addresses in my system obviously)
I thought that since both head and current are pointers to the same thing the address would be the same.
This is not a school assigment. I like to write little scripts to sort of see how things work, I seem to understand things better this way. Play around.
PS - Thank you and not sure if we are to past code on the forum so I did the attached file.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!