title: Why is getchar() reading '\n' after a printf statement?
body: <p><br />
  I'm prompting the user to enter the length of an array, initializing a char[] array with this input, and then prompting the user to type a message to enter into the char[] array.
  <br /><br />
  I'm reading the first character of the user's message with <code>getchar()</code>.
  <br /><br />
  However, <code>getchar()</code> is reading the new-line escape <code>'\n'</code> before it is reading any user input. It seems to be getting <code>'\n'</code> from the previous <code>printf</code> statement that prompts the user...
  <br /><br /><br />
  Here is the relevant code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void) {
  
      int len = 0,
          originalLen = 0;
  
      printf("\n\nWhat is the length of the array? ");
      scanf("%d", &amp;originalLen);
      char str[originalLen]; // intitializing the array
  
      printf("Enter a message to enter into the array: ");
      char target = getchar();
      str[len] = target;
  
      // why is getchar() reading '\n'?
      if (target == '\n') {
          printf("\n...what happened?\n");
      }
      return 0;
  } // end of main
  </code></pre>
  
  <p><br /></p>