title: cout stop working after linker option
body: <p>
  I'm writing a C++ program who takes screenshots. I borrowed the screenshot function from <a href="https://causeyourestuck.io/2016/01/12/screenshot-c-win32-api/" rel="nofollow noreferrer">here</a> and set up a linker option <code>-mwindows</code> like the webpage has mentioned, then things happened. <code>cout</code> stop showing my texts after I set up the linker option. </p>
  
  <p>
  Here is my code, before setting up linker options: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;windows.h&gt;
  using namespace std; 
  
  int main(int argc, char** argv) {
      cout &lt;&lt; "test\n"; 
  
      while (true) {
          cout &lt;&lt; "test2\n"; 
      }
  
      system("pause"); 
      return 0;
  }
  </code></pre>
  
  <p>Here is the function <code>screenshot</code> along with linker option <code>-mwindows</code>: </p>
  
  <pre><code>void screenshot(POINT a, POINT b) {
      // copy screen to bitmap
      HDC     hScreen = GetDC(NULL);
      HDC     hDC     = CreateCompatibleDC(hScreen);
      HBITMAP hBitmap = CreateCompatibleBitmap(hScreen, abs(b.x-a.x), abs(b.y-a.y));
      HGDIOBJ old_obj = SelectObject(hDC, hBitmap);
      BOOL    bRet    = BitBlt(hDC, 0, 0, abs(b.x-a.x), abs(b.y-a.y), hScreen, a.x, a.y, SRCCOPY);
  
      // save bitmap to clipboard
      OpenClipboard(NULL);
      EmptyClipboard();
      SetClipboardData(CF_BITMAP, hBitmap);
      CloseClipboard();
  
      // clean up
      SelectObject(hDC, old_obj);
      DeleteDC(hDC);
      ReleaseDC(NULL, hScreen);
      DeleteObject(hBitmap);
  }
  </code></pre>
  
  <p>What I do know so far is, the program is running good, except cout. </p>
  
  <p>Screenshot is correctly taken, infinite loop is running, and writing files through fstream is also okay if I add it. </p>
  
  <p>And things won't change if I call screenshot anywhere or even never call it (but screenshot is declared), <code>cout</code> still shows nothing. </p>
  
  <p>So the problem is not from the <code>screenshot</code> function. </p>
  
  <p><code>system("pause")</code> does show its texts if I remove the infinite loop. </p>
  
  <p>It'd be helpful if somebody tell me why the linker option stops <code>cout</code> from working. Or do I use linker option in the wrong way? (I think this is nearly impossible because the <code>screenshot</code> function works perfectly)</p>
  
  <p>I'm coding with Dev-C++ 5.11. I set up linker options by adding <code>-mwindows</code> to <strong>Project Option > Parameters > Linker</strong>. </p>
  
  <p>How can I make cout works normally while with the linker option set up so I can take screenshots? Any information would be appreciated. <strong>Thanks.</strong> </p>
  
  
  
  
  
  <p><strong>Edit:</strong> According to my further test, <code>printf</code> has the same behavior to <code>cout</code>, which shows nothing on console. </p>