title: Linked list initialization
body: <p>I trying to create a linked list in C, but I get one more element in the list than I expect.</p>
  
  <pre><code>#define SIZE_OF_LIST 10 
  
  int main()
  {
    struct node* head = NULL;
    struct node* item = NULL;
  
    int i;
  
    head = (struct node*)malloc(sizeof(struct node));
    item = (struct node*)malloc(sizeof(struct node) * 10);
  
    head-&gt;data = 999;
    head-&gt;link = item;
  
    // Create a list of 10 elements
    for (i = 0; i &lt; SIZE_OF_LIST; i++)
      {
        (item+i)-&gt;data = i;
        printf("(item+%d)-&gt;data = %d\n",i,i);
        if (i&lt;SIZE_OF_LIST-1)
        {
            (item+i)-&gt;link = (item+i+1);
             printf("(item+%d-&gt;link = (item+%d+1);\n", i, i);
        }
        else 
        {
            (item+i)-&gt;link = NULL;
            printf("(item+%d-&gt;link = NULL;\n", i);
        }
      }
  
    printf("Items : %d\n", getListLength(head));
    PrintListData(head);
    return 0;
  }
  </code></pre>
  
  <p>So I created 2 functions. One to determine the length of the list, by running through nodes until it find the end node (link=NULL).
  And i created a function which prints out the data of the list.</p>
  
  <pre><code>void PrintListData(struct node* list)
  {
    int i = 0;
    int list_length = getListLength(list);
  
    for (i = 0; i &lt; list_length; i++)
    {
        printf("List[%d] = %d\n", i, (list+i)-&gt;data);
    }
  }
  </code></pre>
  
  <p>So I expect the list to hold head+10 items in the list, but my output is:</p>
  
  <pre><code>Items : 12
  List[0] = 999
  List[1] = 0
  List[2] = 0
  List[3] = 1
  List[4] = 2
  List[5] = 3
  List[6] = 4
  List[7] = 5
  List[8] = 6
  List[9] = 7
  List[10] = 8
  List[11] = 9
  </code></pre>
  
  <p>So it seems like there is an extra element at position 1 of the list? What am I doing wrong?</p>