title: Scanf skips second line of input, always
body: <p>I'm trying to read lines of text data, and store them in a linked list. 
  Input data looks something like this:</p>
  
  <pre><code>David Copperfield
  Charles Dickens
  4250
  24.95
  32.95
  10
  6
  END_DATA
  </code></pre>
  
  <p>The way I read the data is to first read the first line to see if it is END_DATA. If it's not, then I pass the first line into a function which creates a linked list Node with the book data inside. For some reason, scanf does not read the second line after I pass the first line to the function.</p>
  
  <p>When I try to print the Nodes after they've read the data, my output looks like this. </p>
  
  <pre><code>David Copperfield 
  
  0 
  0.000000 
  0.000000 
  0 
  0
  Charles Dickens 
  
  4250 
  24.950001 
  32.950001 
  10 
  6
  Charles Dickens 
  
  0 
  0.000000 
  0.000000 
  0 
  0
  </code></pre>
  
  <p>Source Code is below</p>
  
  <pre><code>#include "lab3p1.h"
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  
  struct NodeRec {
      Book data;
      struct NodeRec *next;
  };
  
  typedef struct NodeRec Node;
  
  float findRevenue(Node *head);
  float totalWholesaleCost(Node *head);
  float totalProfit(Node *head);
  float totalBooksSold(Node *head);
  float averageProfitPerSale(Node *head);
  void printNodes(Node *head);
  
  void insertNode(Node* head, Node* newNode);
  
  Node* createNewNode(char titleS[40]) {
      Node* newNode;
      newNode = malloc(sizeof(Node));
      if (newNode == NULL){
          printf("ERROR ALLOCATING SPACE");
          exit(-1);
      }
      else {
          strcpy(newNode-&gt;data.title, titleS);
          scanf("%40[^\n]*c", (char *)&amp;newNode-&gt;data.author);
  
          scanf ("%i %f %f %i %i", &amp;newNode-&gt;data.number, &amp;newNode-&gt;data.wholesaleprice, &amp;newNode-&gt;data.retailprice, &amp;newNode-&gt;data.wholesalequantity, &amp;newNode-&gt;data.retailquantity);
  
          printf ("%s \n%s \n%i \n%f \n%f \n%i \n%i\n", newNode-&gt;data.title, newNode-&gt;data.author,newNode-&gt;data.number, newNode-&gt;data.wholesaleprice, newNode-&gt;data.retailprice, newNode-&gt;data.wholesalequantity, newNode-&gt;data.retailquantity);
  
      }
  
      return newNode;
  }
  
  
  void readBooks(Node* head) {
  
      char firstline[40];
      char enddataString[40] = "END_DATA";
      scanf("%40[^\n]*c", (char *)&amp;firstline);
  
  
      while (strcmp(firstline, enddataString)) {
  
          Node* newNode = createNewNode(firstline);
          insertNode(head, newNode);
  
          scanf("%40[^\n]*c", (char *)&amp;firstline);
      }
  }
  
  
  
  void insertNode(Node* head, Node* newNode) {
  
      if (head == NULL) {
          head = newNode;
      }
      else {
          Node *preNode, *currentNode;
  
          int n = newNode-&gt;data.number;
          currentNode = head;
  
          while (currentNode != NULL &amp;&amp; (currentNode-&gt;data.number) &gt; n ) {
              preNode = currentNode;
              currentNode = currentNode-&gt;next;
  
          }
          newNode-&gt;next = currentNode;
          preNode-&gt;next = newNode;
      }
  }
  </code></pre>