Thread: typedef confusion (LINKED LIST)

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    144

    typedef confusion (LINKED LIST)

    Part of a code in the book has whats below. They've said that typedef node *list
    and then went onto say that list head.
    So what actually is head now? Is it a structure?


    Code:
    typedef struct node_type
    {
    char data;
    struct node_type *next;
    }node;
    
    typedef node *list;
    list head;

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    A typedef creates an alias of sorts. In your case, node is an alias for struct node_type and list is an alias for node* which is actually then struct node_type*.

    So... head is a struct node_type pointer.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sorting linked list please help with CODE
    By scarlet00014 in forum C Programming
    Replies: 3
    Last Post: 09-27-2008, 11:24 PM
  2. Adding nodes to a linked list
    By bluescreen in forum C Programming
    Replies: 4
    Last Post: 11-09-2006, 01:59 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. Problem with linked list ADT and incomplete structure
    By prawntoast in forum C Programming
    Replies: 1
    Last Post: 04-30-2005, 01:29 AM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM