title: Redirecting stdout output in cpp
body: <p>I've been searching for an answer regarding this issue for a few days now, I hope you guys will be able to assist me. (I've searched and found some solutions, but each has its own issue...).</p>
  
  <p>Here is the thing:
  I'm writing an automation at work, which is responsible for launching an external ".exe" file of a code written by my colleagues. As those programs they write go to customers, I'm not allowed to make any modification to their code. Those programs, once launched, are waiting for specific key strokes, and prints a message when a legal key stroke has been received.</p>
  
  <p>My goal is this:
  To write a program which will execute the external program, send it key strokes, and receive the output from their stdout.
  So far, I have been able to run the program from my program (using ShellExecute), and simulate some sort of keyboard listener (using SendMessage) to the other program. I can see that it works - I can see the output in the tested program's console.</p>
  
  <p>I'm trying to fetch the messages printed on the tested program's shell in real-time (and just get a bulk of data when the program terminates) so that I could analyse it when it occurs.</p>
  
  <p>Those I've tried:</p>
  
  <ul>
  <li>Writing an external batch file with inline output redirection to a text file. </li>
  <li>Using freopen.</li>
  <li>Redirecting the output while exectuing "ShellExecute".</li>
  </ul>