title: C cannot read string after I read an integer
body: <p>Below is my source code. After I read the integer, the program should wait until I type a string and then press enter. However, as soon as I enter the integer, the program exits. Can you tell me where is my fault?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  #include &lt;string.h&gt;
  
  int main()
  {
  
      int n;
      char command[255];
  
      scanf("%d", &amp;n);
      fgets(command, 255, stdin);
  
      return 0;
  }
  </code></pre>
  
  <p>I mention that I also tried to use <code>gets(command)</code>, but I get the same result.</p>