title: %[^\n]s in scanf does not wait for input and gets skipped
body: <p>In the loop in the code below, <code>scanf("%[^\n]s",array)</code> is not working. It does not wait for input and gets skipped. But a space before <code>%</code> fixes the issue. Why?</p>
  
  <p>Here is the wrong program:</p>
  
  <pre><code>#include &lt;string.h&gt;
  #include &lt;stdio.h&gt;
  
  int main()    
  {    
      int t;
      scanf("%d",&amp;t);
      while(t--){
          char arr[199];
          scanf("%[^\n]s",arr);
          printf("%s",arr);
      }
      return 0;
  }
  </code></pre>
  
  <p>Here is right code:</p>
  
  <pre><code>#include &lt;string.h&gt;
  #include &lt;stdio.h&gt;
  
  int main()
  {    
      int t;
      scanf("%d",&amp;t);
      while(t--){
          char arr[199];
          scanf(" %[^\n]s",arr);
          printf("%s",arr);
      }
      return 0;
  }
  </code></pre>
  
  <p>Why does it need a space before <code>%</code> for it to work as expected?</p>