title: C++: cannot see output in VS Code while debugging
body: <p>Today I'm trying to switch from VS2019 to VS Code while keep working with MSVC. This way I will develop in a lightweight and easier environment most of the time, and when I need advanced stuff such as seeing hot paths, I would be able to open VS2019 and do the job. Below is my <code>launch.json</code> configuration</p>
  
  <pre><code>"name": "debug",
  "type": "cppvsdbg",
  "request": "launch",
  "program": "${workspaceFolder}/build/${fileBasenameNoExtension}.exe",
  "args": [],
  "stopAtEntry": false,
  "cwd": "${workspaceFolder}",
  "environment": [],
  "externalConsole": false,
  "preLaunchTask": "compile"
  </code></pre>
  
  <p>The problem is that when debugging the output from <code>std::cout</code> cannot be seen in any window. Setting <code>externalConsole</code> to <code>true</code> opens a new console where the results are the expected ones. Is there a way to see the output of my program without a new console? When I worked with Node some time ago I remember that <code>console.log()</code> was visible in the <code>DEBUG CONSOLE</code> window</p>
  
  <h1>Edit 1</h1>
  
  <p>I added screenshots of the bottom 4 tabs below for clarifying. As u can see <code>DEBUG CONSOLE</code> yeild nothing. The last image is the external console. I found that after ~ 60 secs the <code>DEBUG CONSOLE</code> window displays the right thing, and then I guess freezes again for another ~ 60 secs. The program should display lines in an infinite loop. The last screenshot is took in another debug session, after modifying <code>launch.json</code></p>
  
  <p><a href="https://i.stack.imgur.com/h1Pka.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h1Pka.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/ORT2h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ORT2h.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/8p1Dx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8p1Dx.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/pJDkP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pJDkP.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/rHHdx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rHHdx.png" alt="enter image description here"></a></p>
  
  <h1>Edit 2</h1>
  
  <p>Below are 2 examples. The first one works as intended. The second one does not. In my initial program something similar to the second example was executed</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  using namespace std;
  int main() {
      std::cout &lt;&lt; "Hello world!\n";
  }
  </code></pre>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;Windows.h&gt;
  using namespace std;
  int main() {
      while(true) {
          Sleep(500);
          std::cout &lt;&lt; "Hello world!\n";
      }
  }
  </code></pre>