title: Doubly Linked List Issues?
body: <p>I've created, what I think to be a doubly linked list. The idea is to reverse output of words entered each on a new line, so:</p>
  
  <pre><code>Hello\nAll\n.
  .\nAll\nHello
  </code></pre>
  
  <p>The idea is to traverse my list until <code>'\n'</code> is found, then go in the opposite direction and print that off, go back to where I left, continue traversing until another new line, then go forward again and print etc.</p>
  
  <p>However, my current implementation I can't seem to get to work and I've hit a brick wall, and hints or tips are appreciated!</p>
  
  <pre><code>typedef struct L { 
  char val;
  struct L *next;
  struct L *prev;
  }List;
  
  List *insertList(char val, List *t1 );
  List *createList(void);
  
  int main(void) {
    List *z = createList();
    List *pos = z;
    while (pos != NULL) {
      while ( z-&gt;val != '\n' ) {
          if (z == NULL)
              break;
              z = z-&gt;next;
              pos = z;
  }
      while (z != NULL) {
          printf("%c", z-&gt;val);
          z = z-&gt;prev;
      }
  }
  return 0;
  }
  List *createList(void) {
    List *h = NULL;
    char c;
    do { 
      c =(char)getchar();
      h = insertList(c, h);
    }while(c != '.');
    return h;
   }
  List *insertList( char val, List *t1) {
    List *t = calloc(1, sizeof( List ));
    t-&gt;prev = NULL;
    t-&gt;val = val;
    t-&gt;next = t1;
      if (t1 != NULL) {
       t1-&gt;prev = t;
    }
  return t;
  }
  </code></pre>