title: Why doesn't fgets get the first input?
body: <p>I am creating a few dynamic strings, using a function that uses fgets for getting input from the user. But the first time when I am trying to get the name of the airport, it's just &quot;skip&quot; the fgets automatically put <code>\n</code> in <code>temp</code> and continue the function. all the other inputs are right instead of the first one.</p>
  <pre><code>Please enter name of Airport:
  </code></pre>
  <p>Here it's just skipping the input process and straight printing &quot;enter the address&quot;:</p>
  <pre class="lang-none prettyprint-override"><code>----------Please enter the address-------------
  
  Please enter name of country:
  
  Please enter name of city:
  </code></pre>
  <pre><code>int initAirport(Airport* airportP)
  {
      airportP-&gt;nameOfAirPort = createDynamicString(&quot;Please enter name of Airport:\n&quot;);
      printf(&quot;----------Please enter address-------------\n&quot;);
      airportP-&gt;country = createDynamicString(&quot;Please enter name of country:\n&quot;);
      airportP-&gt;city = createDynamicString(&quot;Please enter name of city:\n&quot;);
      airportP-&gt;address = createDynamicString(&quot; Please enter name of Address:\n&quot;);
      printf(&quot;Please enter house number:\n&quot;);
      scanf(&quot;%d&quot;,&amp;(airportP-&gt;houseNumber));
      return 1;
  }
  </code></pre>
  <pre><code>char* createDynamicString(const char* msg)
  {
      char* str;
      char temp[254];
      printf(msg);
      fgets(temp,254,stdin);
      str = (char*)malloc((strlen(temp)+1) * sizeof(char));
      if (!str)
          return NULL;
      strcpy(str, temp);
      //str[strlen(str) - 1] = 0;
      return str;
  }
  </code></pre>
  <pre><code>#pragma once
  #define MAX 254
  
  typedef struct
  {
      char* nameOfAirPort;
      char* country;
      char* city;
      char* address;
      int houseNumber;
  
  } Airport;
  
  int initAirport(Airport* pNameOfAirport);
  void addNumberSignToString(char* stringOfNumberSign);
  void printNameOfAirport(const Airport* pNameOfAirport);
  int isSameAirport(Airport* airport1P, Airport* airport2P);
  int isAirportName(Airport* airportP, char* airportName);
  void freeAirport(Airport* airportP);
  </code></pre>