title: How to read line with space through redirection operator?
body: <p>I am using command like <code>./a &lt; input.txt &gt; output.txt</code> to execute code</p>
  
  <p>First, I tried to copy <code>input.txt</code> to <code>output.txt</code>, but I encounter some problem. Following is what I already tried.</p>
  
  <p>1.copy all input content, but <code>scanf</code> will stop when it encounter space(and then do next iterate), even in same line</p>
  
  <pre><code>char buffer[1024]
  while(scanf("%s",buffer)==1){
        printf("%s\n",buffer);
  }
  </code></pre>
  
  <p>so expected answer is</p>
  
  <pre><code>hi abc
  </code></pre>
  
  <p>but what I get in <code>1</code> is</p>
  
  <pre><code>hi
  abc
  </code></pre>
  
  <p>2.I tried modify <code>scanf</code> format, it only stop when encounter change line</p>
  
  <pre><code>scanf("%[^\n]",buffer)
  </code></pre>
  
  <p>but it will just only output one line, miss rest of text.</p>
  
  <p>Are there any suggestion? Thanks! </p>