#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    11
    Rep Power
    0

    Which Address is this..?


    Code:
    int a;
    printf("address is %d", &a);
    Which address is this..? I mean is this a compiler generated address i.e. virtual address or the loader given physical address in the RAM..?

    As it prints different address every time, I guess it must be address in the RAM. Just want to make sure.

    Please provide any links which give reference to your answer.

    Thanks
    Adorn
  2. #2
  3. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    248
    Sounds like a homework question to me...

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw
  4. #3
  5. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,782
    Rep Power
    4302
    Incidentally, that code is wrong because it assumes that sizeof(pointer) == sizeof(int), which is a wrong assumption to make. For instance, on many 64 bit compilers (such as x86 compilers like gcc, Visual C++ etc.), int is 32 bit and pointer is 64 bit. What you want to do is use %p instead of %d in the format string.

    To the original poster: Why do you want links?? Can't you just check the assembler and verify for yourself (or tell your teacher that Scorpy said so!)
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    11
    Rep Power
    0
    Hey hey..what is going on guys..?
    I mean I do not ask homework questions on forums..I do it myself..

    If you do not want to answer please don't..nobody has forced you to do so...but please do not apply your "extra" intelligence to judge what someone is doing. Because

    1. My school does not give these kinda 1 line answer homeworks, your might be used to..
    2. And what do you mean by "why you want links..?"
    Are you afraid that someone will test your knowledge..?

    I was about to reply to mitakeet but decided to leave it..but if overall thinking is going like 10 yr old kids i am gonna say something.

    @Scorpions4ever for "Can't you just check the assembler and verify for yourself":: Who the hell are you to say this..? I mean this is not your forum.. You do not want to answer..keep quite!! You do NOT have moral right to say "try yourself"!!

    Don't mind if I'm too harsh.. but this is what happens when some senselessly wrong judgement is built up.

    Thanks
    Adorn

    Comments on this post

    • mitakeet disagrees : You are wasting your time here! Go away!
    • ptr2void disagrees : You are wasting your time period, for exactly the reason Scorps said below.
  8. #5
  9. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,782
    Rep Power
    4302
    Originally Posted by adorn
    @Scorpions4ever for "Can't you just check the assembler and verify for yourself":: Who the hell are you to say this..? I mean this is not your forum.. You do not want to answer..keep quite!! You do NOT have moral right to say "try yourself"!!

    Don't mind if I'm too harsh.. but this is what happens when some senselessly wrong judgement is built up.

    Thanks
    Adorn
    Last I checked, it wasn't your forum either. And my answer was a perfectly valid one, only you sound like the type that needs to be spoon-fed everything. I repeat:
    "Check the assembler and verify for yourself".
    It isn't that hard at all. All you have to do is tell your compiler to send out the assembler output (all C compilers can do this. gcc uses -S option to do this, for example) and then check for yourself. If you do it this way, at least you've learned something new and probably will understand how things work. If I hand you the answer on a plate, you won't learn anything new.

    Don't mind if I'm too harsh, but if you're not willing to do your own exploration, maybe you should choose another career.

    Comments on this post

    • ptr2void agrees : Well said!
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    11
    Rep Power
    0
    1. I never acted like this is my forum.
    2. After your 1st reply only I had tried the thing and got the answer.. if you observe, In my 2nd post I am not asking for answer.
    3. If you think asking for the link is spoon-feeding what can I say.. I think I was asking for more information to read, to know.

    Thanks for being so careful about my career.

    Actually writing this reply I was not this cool or good-worded. But in between I don't know what happened...I felt like the person I am talking to is far more knowledgeable and this is me paying respect to your knowledge. Because it is always very easy to write spicy words but difficult is to go beyond this.

    Thanks
    Adorn

IMN logo majestic logo threadwatch logo seochat tools logo