Re: confused theaddress of struct member

Discussion in 'C++' started by SG, May 28, 2013.

  1. SG

    SG Guest

    On May 28, 11:54 am, Ed wrote:

    > typedef struct Test_tag
    > {
    >     int a;
    >     char Data[32];
    >
    > } Test;


    [snip]

    > my question:
    > why these address are same in (2) and (3)?
    >
    > pObj->Data == &pObj->Data?


    Why do you expect them to be different? Data is an array. Do you know
    what an array is? Hint1: An array is not a pointer. Hint2: There is
    something called "array-to-pointer decay".

    Check out the C FAQ's chapter on arrays and pointers:
    http://c-faq.com/aryptr/

    Cheers!
    SG
     
    SG, May 28, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Victor Bazarov
    Replies:
    14
    Views:
    543
    Francesco S. Carta
    Oct 2, 2009
  2. John Bode
    Replies:
    0
    Views:
    184
    John Bode
    May 28, 2013
  3. James Kuyper

    Re: confused the address of struct member like this

    James Kuyper, May 28, 2013, in forum: C Programming
    Replies:
    1
    Views:
    204
    Keith Thompson
    May 28, 2013
  4. Malcolm McLean

    Re: confused the address of struct member like this

    Malcolm McLean, May 28, 2013, in forum: C Programming
    Replies:
    0
    Views:
    186
    Malcolm McLean
    May 28, 2013
  5. Victor Bazarov
    Replies:
    3
    Views:
    174
    Jorgen Grahn
    May 29, 2013
Loading...

Share This Page