How are memory addresses distributed in C for this example?
I was toying a bit with pointers on Unix based OS(Arch) running. I read this line: Code begins at the same fixed address for all processes. Computer Systems: A Programmer's Perspective (CS:APP)(Randal E. Bryant & David R. O'Hallaron) I had decided to try for myself and I have no clue why the addresses of main differ in the two examples. int main() { void *p = main; int *c; printf("main is %p", p); printf("c is %p", c); } This one outputs lets say main is 0x564873bd3139c is (nil)%. If I delete, recompile and rerun the executable it will be still the same address. Now if I modify my code to: #in
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.