title: Simple Auction system in C - tips?
body: <p>I wrote this program in C for a small auction system using information gathered from a file. The auction system should store bids, apply starting bids/minimum increase bids to a list, and then display the results via a menu system. I believe I have achieved the objective of the project, but I am now attempting to simplify my code.</p>
  
  <p>I am unsure if my code is at all correct, or if there is an easier way to layout the information using less code. Any tips would also be very much appreciated! Thank you for your time.</p>
  
  <p>The input file looks like this</p>
  
  <pre><code>500 40
  100 20
  20 7
  300 55
  700 120
  </code></pre>
  
  <p>Where the first number is the "Auction Starting Bid"</p>
  
  <p>and the second number is the "Auction Minimum Increase" </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  
  //int main
  int main() {
  
  //open input text
      FILE * ifp;
      ifp = fopen("input.txt", "r");
  
      printf("Welcome to the Silent Auction\n");
      printf("\nPlease make a selection from the following:\n");
  
      int number = 1;
      int starting_bid1 = 0;
      int starting_bid2 = 0;
      int starting_bid3 = 0;
      int starting_bid4 = 0;
      int starting_bid5 = 0;
  
      int au1_start, au1_min, au2_start, au2_min, au3_start, au3_min, au4_start, au4_min, au5_start, au5_min;
      char choice [20];
  
      fscanf(ifp, "%d %d", &amp;au1_start, &amp;au1_min);
      fscanf(ifp, "%d %d", &amp;au2_start, &amp;au2_min);
      fscanf(ifp, "%d %d", &amp;au3_start, &amp;au3_min);
      fscanf(ifp, "%d %d", &amp;au4_start, &amp;au4_min);
      fscanf(ifp, "%d %d", &amp;au5_start, &amp;au5_min);
  
      printf("\nView Auctions [VIEW]\nBid on an Auction [BID]\nClose Auctions [CLOSE]\n");
      scanf("%s", &amp;choice);
  
      if (strcmp(choice, "VIEW", "view", "View") == 0) {
  
              printf("\nNumber    Current Bid    Minimum Increase\n");
  
              if (starting_bid1 &lt; au1_start){
                  printf("1         $%d             $%d\n", starting_bid1, au1_start);
              }
              else{
                  printf("1         $%d             $%d\n", starting_bid1, au1_min);
              }
  
              if (starting_bid2 &lt; au2_start){
                  printf("2         $%d             $%d\n", starting_bid2, au2_start);
              }
              else{
                  printf("2         $%d             $%d\n", starting_bid2, au2_min);
              }
  
              if (starting_bid3 &lt; au3_start){
                  printf("3         $%d             $%d\n", starting_bid3, au3_start);
              }
              else{
                  printf("3         $%d             $%d\n", starting_bid3, au3_min);
              }
  
              if (starting_bid4 &lt; au4_start){
                  printf("4         $%d             $%d\n", starting_bid4, au4_start);
              }
              else{
                  printf("4         $%d             $%d\n", starting_bid4, au4_min);
              }
  
              if (starting_bid5 &lt; au5_start){
                  printf("5         $%d             $%d\n", starting_bid5, au5_start);
              }
              else{
                  printf("5         $%d         D    $%d\n", starting_bid5, au5_min);
              }
          }
  
      else if (strcmp(choice, "BID", "bid", "Bid") == 0) {
              printf("\nWhich auction would you like to bid on?\n");
              scanf("%d", &amp;number);
  
                  switch (number) {
                      case 1:
                          printf("The minimum bid is $%d.\n", au1_start);
                          printf("How much would you like to bid?\n");
                          scanf("%d", &amp;starting_bid1);
                          if (starting_bid1 &lt; au1_start){
                              printf("Sorry, that bid is not high enough.\n");
                          }
                          break;
                      case 2:
                          printf("The minimum bid is $%d.\n", au2_start);
                          printf("How much would you like to bid?\n");
                          scanf("%d", &amp;starting_bid2);
                          if (starting_bid2 &lt; au2_start){
                              printf("Sorry, that bid is not high enough.\n");
                          }
                          break;
                      case 3:
                          printf("The minimum bid is $%d.\n", au3_start);
                          printf("How much would you like to bid?\n");
                          scanf("%d", &amp;starting_bid3);
                          if (starting_bid3 &lt; au3_start){
                              printf("Sorry, that bid is not high enough.\n");
                          }
                          break;
                      case 4:
                          printf("The minimum bid is $%d.\n", au4_start);
                          printf("How much would you like to bid?\n");
                          scanf("%d", &amp;starting_bid4);
                          if (starting_bid4 &lt; au4_start){
                              printf("Sorry, that bid is not high enough.\n");
                          }
                      case 5:
                          printf("The minimum bid is $%d.\n", au5_start);
                          printf("How much would you like to bid?");
                          scanf("%d", &amp;starting_bid5);
                          if (starting_bid5 &lt; au5_start){
                              printf("Sorry, that bid is not high enough.\n");
                          }
                      default:
                          printf("\n");
                  }
              }
      else if (strcmp(choice, "CLOSE", "close", "Close") == 0) {
              if (starting_bid1 &gt;= au1_start){
                  printf("\nAuction 1 sold for %d.\n", starting_bid1);
              }
              else{
                  printf("\nAuction 1 did not sell.\n");
              }
  
              if (starting_bid2 &gt;= au2_start){
                  printf("Auction 2 sold for %s.\n", starting_bid2);
              }
              else{
                  printf("Auction 2 did not sell.\n");
              }
  
              if (starting_bid3 &gt;= au3_start){
                  printf("Auction 3 sold for %s.\n", starting_bid3);
              }
              else{
                  printf("Auction 3 did not sell.\n");
              }
              if (starting_bid4 &gt;= au4_start){
                  printf("Auction 4 sold for %s.\n", starting_bid4);
              }
              else{
                  printf("Auction 4 did not sell.\n");
              }
  
              if (starting_bid5 &gt;= au5_start){
                  printf("Auction 5 sold for %s.\n", starting_bid5);
              }
              else{
                  printf("Auction 5 did not sell.\n");
              }
      }
      else{
          printf("\nPlease choose either VIEW, BID, or CLOSE.\n");
      }
  
  // formatting
      printf("\n");
  
  //close file
      fclose(ifp);
  
  //return main
  return 0;
  }
  </code></pre>
  
  <p><strong>Bold represents user input</strong></p>
  
  <p>The final product should look like:</p>
  
  <pre><code>Welcome to the Silent Auction 
  
  Please make a selection from the following: 
  View Auctions [VIEW] 
  Bid on an Auction [BID] 
  Close Auctions [CLOSE] 
  </code></pre>
  
  <p><strong>VIEW</strong> </p>
  
  <pre><code>Number Current Bid Minimum Increase 
  1  $0.00  $500.0 
  2  $0.00  $100.00 
  3  $0.00  $20.00 
  4  $0.00  $300.00 
  5  $0.00  $700.00 
  
  Please make a selection from the following: 
  View Auctions [VIEW] 
  Bid on an Auction [BID] 
  Close Auctions [CLOSE] 
  </code></pre>
  
  <p><strong>BID</strong> </p>
  
  <pre><code>Which auction would you like to bid on? 
  </code></pre>
  
  <p><strong>3</strong> </p>
  
  <pre><code>The minimum bid is $20.00. 
  How much would you like to bid? 
  </code></pre>
  
  <p><strong>21</strong> </p>
  
  <pre><code>Please make a selection from the following: 
  View Auctions [VIEW] 
  Bid on an Auction [BID] 
  Close Auctions [CLOSE] 
  </code></pre>
  
  <p><strong>CLOSE</strong></p>
  
  <pre><code>Auction 1 did not sell. 
  Auction 2 did not sell. 
  Auction 3 sold for $21.00! 
  Auction 4 did not sell. 
  Auction 5 did not sell. 
  </code></pre>