Thread: simple question

  1. #1
    Unregistered
    Guest

    Unhappy simple question

    Can anyone tell me how I can create an array of linked lists?

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    Create an array of pointers and let each pointer point to the start of a linked list.

  3. #3
    Unregistered
    Guest

    Red face

    How do I do that ???

  4. #4
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380


    I don't know, but maybe something like this?

    Code:
    /* For improving code readability */
    typedef struct node *list_ptr;
    typedef struct node *node_ptr;
    
    /* Also for improving code readability */
    typedef enum
    {
        FIRST_LIST,
        SECOND_LIST,
        NR_OF_LISTS
    } list_index;
    
    /* The basic element of a list */
    struct node
    {
        int some_useful_data;
        node_ptr next_node;
    };
    
    /* Some lists */
    list_ptr list1;
    list_ptr list2;
    
    /* An array of lists */
    list_ptr array_of_lists [NR_OF_LISTS];
    
    /* Filling the array */
    array_of_lists [FIRST_LIST] = list1;
    array_of_lists [SECOND_LIST] = list2;

  5. #5
    Unregistered
    Guest
    ??? You have really lost me....can that be done more easily...that all seems way beyond me

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple question regarding variables
    By Flakster in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2005, 08:10 PM
  2. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  3. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  4. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 12:15 PM
  5. simple fgets question
    By theweirdo in forum C Programming
    Replies: 7
    Last Post: 01-27-2002, 06:58 PM