Assigning memory address of member struct to pointer.

This is a discussion on Assigning memory address of member struct to pointer. within the C++ Programming forums, part of the General Programming Boards category; I'm having a bit of trouble with pointers lately....still learnin more about them But more specifically then that, i'm having ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    220

    Assigning memory address of member struct to pointer.

    I'm having a bit of trouble with pointers lately....still learnin more about them But more specifically then that, i'm having trouble assigning the memory address of a structure member to a pointer.. Anyone know the code for this?

    Code:
    typedef struct
    {
        int x;
        int y;
        int z;
    }
    _3DStruct_;
    Code:
    _3DStruct_ ptOne;
    That is just to give you an idea about what var's are in the struct and the name of the struct.

    The names of my pointers are 'pX', 'pY', and 'pZ', they need the memory addresses of x,y, and z assigned to them respectively. Any idea?
    OS: Windows XP Pro CE
    IDE: VS .NET 2002
    Preferred Language: C++.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    You should be able to do something
    int* pX = &ptOne.x;

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    220
    >You should be able to do something
    int* pX = &ptOne.x;

    Thank you It worked.
    OS: Windows XP Pro CE
    IDE: VS .NET 2002
    Preferred Language: C++.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 05:23 AM
  2. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 07:17 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. memory allocation for flexible array member of struct
    By jcarouth in forum C Programming
    Replies: 3
    Last Post: 09-11-2005, 01:19 PM
  5. towers of hanoi problem
    By aik_21 in forum C Programming
    Replies: 1
    Last Post: 10-02-2004, 02:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21