title: reading from a text file using fscanf()
body: <p>I'm having trouble figuring out what went wrong in my code. I think that my while loop didn't read the file correctly, I was trying to print out the customer name but nothing shows up.</p>
  
  <p>for example, I have a file like this.</p>
  
  <pre><code>Smith 3 Sweater $22.50
  Reich 3 Umbrella $12.50
  Smith 1 Microwave $230.00
  Lazlo 1 Mirror $60.00
  Flintstone 5 Plate $10.00
  Lazlo 1 Fridge $1200.00
  Stevenson 2 Chair $350.00
  Smith 10 Candle $3.50
  Stevenson 1 Table $500.00
  Flintstone 5 Bowl $7.00
  Stevenson 2 Clock $30.00
  Lazlo 3 Vase $40.00
  Stevenson 1 Couch $800.00
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  struct orders_tag {
      int number_of_orders;
      char item_name[20];
      double price;
  };
  
  typedef struct orders_tag order;
  
  struct customer_tag {
      char name[30];
      order total_order[100];
  };
  
  typedef struct customer_tag customer;
  
  int main(void) {
      FILE *infile;
      customer cus_array[20];
      customer c;
      int customerCounter = 0;
  
      setvbuf(stdout, NULL, _IONBF, 0);
  
      infile = fopen("input.txt", "r");
  
      if (infile == NULL) {
          printf("Couldn't open the fire.");
          return 1;
      }
  
      while (fscanf(infile, "%s %d %s %lf", c.name,  c.total_order[customerCounter].number_of_orders
          , c.total_order[customerCounter].item_name,  c.total_order[customerCounter].price) != EOF) {
          cus_array[customerCounter] = c;
          customerCounter++;
      }
  
      int j;
      for(j = 0; j &lt; customerCounter; j++) {
          printf("%s", cus_array[j].name);
      }
      return 0;
  }
  </code></pre>