title: fgets() not working in a function
body: <p>I am writing a program which uses fgets() to scan a 3 Char long string as an Airport code for Departure and arrival. When I write the statement outside its method  (in the main) it works fine however inside it does not wait for input and leaves the variables blank.</p>
  
  <pre><code>void newFlight ()
      {
          printf("\n");
          printf("============= CREATE A NEW FLIGHT ============= \n");
          printf("Type 0 at any point to exit to main menu. \n");
          printf("\n");
  
          printf("EnterFlight ID (0 to cancel) : ");
          scanf("%d", &amp;flyList[curFly].flightID);
  
          char codeA [4];
          printf ("Enter Destination (Airport Code): ");
          fgets(codeA, 3, stdin);
          strcpy(codeA, flyList[curFly].arrive);
          printf("%s   %s \n", codeA, flyList[curFly].arrive);  //TEST
  
          printf("Enter Place Of Departure: ");
          char codeD[4];
          scanf("%s", codeD);
          strcpy(codeD, flyList[curFly].depart);
          printf("%s   %s \n", codeD, flyList[curFly].depart);  //TEST
  
          printf("Enter Date Of Departure (DD MM YYYY): ");
          scanf("%hd %hd %hd", &amp;flyList[curFly].timeOfDep.day, &amp;flyList[curFly].timeOfDep.month, &amp;flyList[curFly].timeOfDep.year);
  
          printf("Enter Time Of Departure (HH MM)in 24Hr Format: ");
          scanf("%hd %hd", &amp;flyList[curFly].timeOfDep.hour, &amp;flyList[curFly].timeOfDep.minute);       
  
          curFly++;
      }
  </code></pre>