Thread: Referencing pointer inside a structure pointer

  1. #1
    Registered User
    Join Date
    Jan 2010

    Referencing pointer inside a structure pointer


    I have a structure as follows

    struct arptCd
        char code[ARPCDLEN];
    struct arptList
            struct arptCd arpt;
            struct arptCd *next;
    struct halfTurnTime
            struct arptList *arpt;
            float pctMgtArr;
            float pctMgtDep;
            float minmDep;
            float minmArr;
    struct halfTurnTimeList{
            struct halfTurnTime halfTurnTimeData;
            struct halfTurnTime *next;
    Here halfTurnTimeList is a linked list whose first element is pointer to arptList which is another linked list. I have allocated memory of halfTurnTimeList and pute it into variable name called node. I have created the linked list of arpt.But when i am trying to assign address of first note into the first element of halfTurnTimeList by following assignment


    Compiler showing error "struct halfTurnTimeListâ has no member named arpt".

    I made following task

    struct halfTurnTimeList *node=NULL
    node=calloca as halfTurnTimeList
    created linked list of Arpt node
    node->arpt=firstArptNode. firstArptNode is the address of the first node.

    How can i access a pointer member of structure pointer.

    Thanks in advance

  2. #2
    Registered User
    Join Date
    Nov 2010
    Long Beach, CA
    node is of type halfTurnTimeList, which only has 2 elements, halfTurnTimeData and next. It's halfTurnTimeData that is of type halfTurnTime and has an element named aprt. Thus, you need node->halfTurnTimeData->arpt = firstArptNode.

  3. #3
    Registered User
    Join Date
    Jan 2010
    Thanks a lot for pointing out the error.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. union inside structure
    By vijay s in forum C Programming
    Replies: 1
    Last Post: 12-03-2009, 07:21 AM
  2. Replies: 5
    Last Post: 04-04-2009, 03:45 AM
  3. Problem referencing structure elements by pointer
    By trillianjedi in forum C Programming
    Replies: 19
    Last Post: 06-13-2008, 05:46 PM
  4. Can a pointer point to different data structure?
    By franziss in forum C Programming
    Replies: 9
    Last Post: 09-04-2005, 11:51 AM
  5. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM