title: C - Trying to make an array of LinkedList pointers
body: <p>I'm trying to create a <code>HashTable</code> in C where each 'bucket' is a pointer to a <code>LinkedList</code>. That is, I need to create an array of <code>LinkedList</code> pointers.</p>
  
  <p>As of now, <code>SomeHashTable-&gt;Buckets[i]</code> is returning a non-pointer <code>LinkedList</code>. I've been looking for answers everywhere and I just can't find anything. Perhaps I'm overlooking something? I've given my current code below.</p>
  
  <p><strong>HashTable.h</strong></p>
  
  <pre><code>#include "LinkedList.h"
  
  typedef struct HashTable
  {
    LinkedList* Buckets[1009];
  } HashTable;
  
  //Creates new hashtable
  HashTable* HashTable_new();
  
  //Hashes and adds a new entry
  void HashTable_add(HashTable* Table, int data);
  </code></pre>
  
  <p><strong>HashTable.c</strong></p>
  
  <pre><code>#include "HashTable.h"
  HashTable* HashTable_new()
  {
    HashTable* newTable = (HashTable*)malloc(sizeof(HashTable));
    newTable-&gt;Buckets = malloc(1009 * sizeof(LinkedList*));
  
    //Create linked lists
    for (int i = 0; i &lt; 1009; i++)
    {
      newTable-&gt;Buckets[i] = LinkedList_new();
    }
  
    return newTable;
  }
  
  void HashTable_add(HashTable* Table, int data)
  {
    int index = data % 1009;
  
    //Get bucket to hash to
    LinkedList* BucketHead = (Table-&gt;Buckets[index]);
    //Hash it iiinnnn real good
    LinkedList_add_at_end(BucketHead, data);
  }
  </code></pre>
  
  <p>The linked List structs for reference: </p>
  
  <pre><code>typedef struct LinkedListNode {
      int data;
      struct LinkedListNode *next;
      struct LinkedListNode *prev;
  } LinkedListNode;
  
  typedef struct LinkedList {
      struct LinkedListNode *first;
      struct LinkedListNode *last;
  } LinkedList;
  </code></pre>