Awesome.
Assigning a pointer value to an int most certainly isn't good practice. The program was designed to show the fundamentals of pointers and what really is going on under the cover, even though I am just refreshing my own memory.
I appreciate the insight and it definitely works. Kudos to you, Banfa, for now I know where my studies are going to take me next. Thanks a lot!
User Profile
Collapse
-
Why do I get a segmentation fault when I dereference a typecast?
Please review my pastebin. I commented exactly where it occurs, and how GDB will not access my variable.
I made a program to prove that you can store an address into an unsigned int and use it as a pointer. It works on old 32bit machine, but not on my 64 bit. I can only assume it is because of my compiler??
...Code://I am trying to figure out why I get a segmentation fault at "*((char *) hacky_nonpointer)"
Last edited by Niheel; Dec 16 '11, 05:38 AM. Reason: full code is better for future reference, pastebin link is still there
No activity results to display
Show More
Leave a comment: