title: Why can't I redirect output from WriteConsole?
body: <p>In the following program I print to the console using two different functions</p>
  
  <pre><code>#include &lt;windows.h&gt;
  
  int main() {
      HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
      DWORD byteswritten;
      WriteConsole(h, "WriteConsole", 12, &amp;byteswritten, NULL);
      WriteFile(h, "WriteFile", 9, &amp;byteswritten, NULL);
  }
  </code></pre>
  
  <p>If when I execute this program and redirect it's output using <code>a &gt; out.txt</code> or <code>a 1&gt; out.txt</code> nothing gets printed to the console (as expected) but the contents of <code>out.txt</code> are only</p>
  
  <pre><code>WriteFile
  </code></pre>
  
  <p>What is different between the two that allows calls to <code>WriteFile</code> to be redirected to the file and calls to <code>WriteConsole</code> to go to ... nowhere</p>
  
  <p>Tested with gcc and msvc on windows 10</p>