title: Writing time to a file in C using time.h
body: <p>So basically I've got this project in C - I have to design a customer/order system, in which the customer can make multiple orders but each order is limited to a single product type. I created a struct 'orders' which contains the customer ID, product name, price, and the order time. Here is the code to calculate time:</p>
  
  <pre><code>        // computing order time
          time_t timeorder;
          char * displayT;
          timeorder = time(NULL);
          // convert time to string so that it can be displayed
          displayT= ctime(&amp;timeorder);
          printf("Your order time is: %s\n", displayT); //check if time displays correctly
          newOrders11[count13].timeorder = displayT;
  </code></pre>
  
  <p>Immediately after, the struct 'orders' is written to file. After the user makes an order, he/she should be available to view his/her LATEST order after entering his/her ID number. However, when the order is read from the file, the first order the user made (rather than the latest) is displayed. Here is the code for reading from file:</p>
  
  <pre><code> while (count13&lt;=MAXORDERSTOBEMADE &amp;&amp; (fread(&amp;newOrders11[count13], sizeof(struct orders), 1, filePointer))==1)
  {
      if(ID == newOrders11[count13].ID) {
          printf("These are the details for order %i\n", count13);
  
          if(count13&gt;=0)
          printf("Customer ID: %d\n", newOrders11[count13].ID);
          printf("Product Name: %s\n", newOrders11[count13].productname);
          printf("Price: %f\n", newOrders11[count13].total);
      } else {
          continue;
      }
      count13++;
  }
  </code></pre>
  
  <p>Does any one know how I should go about this? Sorry, I am still a C beginner. This is my first program in C.</p>