title: Creating and Printing a Linked List with words from user input
body: <p>I am trying to create a linked list which stores words from user input and then prints them.
  My code works, however I want to modify it to prompt the user after every word, until the last word which is "end".
  Any hints as to how I can do this?
  RIght now the code prompts the user and the user can enter words separated by spaces until they press enter, then the linked list is printed</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;ctype.h&gt;
  
  typedef struct list *ptr;
  typedef struct list {
      char data;
      ptr next;
  } node;
  
  void insert(ptr *H, char c);
  void freeList(ptr *H);
  void printList(ptr H);
  
  int main() {
      ptr H = NULL;
      int c;
  
      printf("enter a single word:\n");
  
      while (((c = getchar()) != EOF) &amp;&amp; c != '\n')
          insert(&amp;H, (char) c);
  
      printList(H); /*print the list*/
      freeList(&amp;H); /*free the list*/
      printf("\n");
      prinf("Please enter a single word:\n");
  
      return 0;
  }
  
  void insert(ptr *H, char c) {
      while (*H)
          H = &amp;(*H)-&gt;next;
  
      *H = malloc(sizeof(**H));
      (*H)-&gt;data = c;
      (*H)-&gt;next = NULL;
  }
  
  void freeList(ptr *H) {
  
      while (*H) {
          ptr tmp = *H;
          *H = (*H)-&gt;next;
          free(tmp);
      }
  }
  
  void printList(ptr H) {
      // NOTE: No need for a pointer-to-pointer here.
      while (H) {
          printf("%c", H-&gt;data);
          H = H-&gt;next;
      }
  }
  </code></pre>