title: Why does scanf ask twice for input when there's a newline at the end of the format string?
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  char *method1(void)
  {
      static char a[4];
      scanf("%s\n", a);
      return a;
  }
  
  int main(void)
  {
      char *h = method1();
      printf("%s\n", h);
      return 0;
  }
  </code></pre>
  
  <p>When I run the code above, the prompt is asking me <em>twice</em> for input (I only use <code>scanf</code> once in the code). Why is that?</p>
  
  <p>(I entered 'jo'; it asked for more input, so I entered 'jo' again.  Then it only printed out 'jo' once.)</p>