title: How to read from input until newline is found using scanf()?
body: <p>I was asked to do a work in C when I'm supposed to read from input until there's a space and then until the user presses enter.
  If I do this:</p>
  
  <pre><code>scanf("%2000s %2000s", a, b);
  </code></pre>
  
  <p>It will follow the 1st rule but not the 2nd.<br>
  If I write:</p>
  
  <pre>I am smart</pre>
  
  <p>What I get is equivalent to:<br>
  a = "I";<br>
  b = "am";<br>
  But It should be:<br>
  a = "I";<br>
  b = "am smart";<br></p>
  
  <p>I already tried:</p>
  
  <pre><code>scanf("%2000s %2000[^\n]\n", a, b);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>scanf("%2000s %2000[^\0]\0", a, b);
  </code></pre>
  
  <p>In the 1st one, it waits for the user to press <kbd>Ctrl</kbd>+<kbd>D</kbd> (to send EOF) and that's not what I want.
  In the 2nd one, it won't compile. According to the compiler:</p>
  
  <blockquote>
    <p>warning: no closing ‘]’ for ‘%[’ format</p>
  </blockquote>
  
  <p>Any good way to solve this?</p>