title: some fgets cannot work in C programming
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main()
  {
      int sel_1, sel_2, telno[12], price = 0, sum = 0, i;
      char pkg[2], name[10], addrs[30], name_1[50][50], addrs_1[50][50];
  
      printf(" Lunch4You Enterprise\n Delivery Service Subscription System\n");
      printf("==========================================================================");
      printf("\nPackage that we have:\n 1. Package A: 20days/month(5days/week) - RM60/month");
      printf("\n 2. Package B: 12days/month(3days/week) - RM45/month");
      printf("\n 3. Package C: 8days/month(2days/week) - RM35/month");
  
      do
      {
          printf("\nPlease select the package: ");
          scanf("%d", &amp;sel_1);
      }
      while (sel_1 != 1 &amp;&amp; sel_1 != 2 &amp;&amp; sel_1 != 3);
  
      switch (sel_1)
      {
          case 1: strcpy(pkg, "A"); price = 60;
                  break;
          case 2: strcpy(pkg, "B"); price = 45;
                  break;
          case 3: strcpy(pkg, "C"); price = 35;
                  break;
      }
  
      printf("\n\nYou have selected Package %s.", pkg);
  
      do
      {
          printf("\nHow many receiver of lunchbox?: ");
          scanf("%d", &amp;sel_2);
      }
      while (sel_2 &gt; 5 || sel_2 &lt; 1);
  
      sum = sel_2 * price;
      printf("\n\nPlease enter the information below:\nName of subscriber: ");
      scanf("%s", &amp;name);
      printf("\nAddress (Pick-up): ");
      fgets(addrs,30,stdin);
  
      for (i = 0; i &lt; sel_2; ++i)
      {
          printf("Name of receiver (%d): ", i + 1);
          fgets(name_1[i], 50, stdin);
          printf("Address(Receiver)(%d): ", i + 1);
          fgets(addrs_1[i], 50, stdin);
          printf("Tel No (%d)", i + 1);
          scanf("%d", &amp;telno[i]);
      }
  
      printf("\n\nYour information for lunchbox delivery are:");
      printf("\nPackage : %s", pkg);
      printf("\nPick-up Address: %s", addrs);
  
      for (i = 0; i &lt; sel_2; ++i)
      {
          printf("\nReceiver %d: %s, %s\n\t\t%d", i + 1, name_1[i], addrs_1[i], telno[i]);
      }
      printf("\n\nTotal fee: RM%d\n", sum);
  
      return 0;
  }
  </code></pre>
  
  <p>$some fgets cannot work, it just skip to the next fgets then wait for users to enter.(in this case, the fgets(addrs) and fgets(name_1) in the 'for loop' cannot work) can I know why and how to solve this problem? thks.</p>