title: Nested structure pointer cannot access memory at address 0x8
body: <p>I'm trying to do a basic text editor with linked lists for school project. When i tried to take a letter from keyboard program crushed cause of a runtime error. I watched currentLine->headLetter which is in void insertLetter function with debugger it says cannot access memory at address 0x8. I couldnt understand why it is crushing?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;conio.h&gt;
  #include &lt;windows.h&gt;
  
  struct sentence {
      struct sentence *next;
      struct sentence *prev;
      char letter;
  };
  
  struct sentence *currentLetter;
  
  struct line{
      struct line *next;
      struct line *prev;
      struct sentence *headLetter;
      struct sentence *lastLetter;
  };
  
  struct line *headLine;
  struct line *lastLine;
  struct line *currentLine;
  
  void gotoxy(int x, int y)
  {
    static HANDLE h = NULL;
    if(!h)
      h = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD c = { x, y };
    SetConsoleCursorPosition(h,c);
  }
  
  void insertFirstLine ()
  {
     struct line *link = (struct line*) malloc(sizeof(struct line));
  
     headLine = lastLine = currentLine;
     headLine = link;
     link-&gt;prev = NULL;
     link-&gt;next = NULL;
  }
  
  void insertLetter (char data)
  {
      struct sentence *link = (struct sentence*) malloc(sizeof(struct sentence));
      link-&gt;letter = data;
  
          currentLine-&gt;headLetter = link;
          currentLine-&gt;lastLetter = link;
          currentLetter = link;
          link-&gt;next = NULL;
          link-&gt;prev = NULL;
  
  }
  
  void newFile ()
  {
      char control;
      while (1)
      {
          control = _getch();
          insertLetter(control);
      }
  }
  
  int main ()
  {
      insertFirstLine();
      newFile();
      return 0;
  }
  </code></pre>