Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to redirect "cout" and "print" to a microsoft Windows 10 window? #571

Open
GitRjc opened this issue Jul 5, 2021 · 2 comments
Open

Comments

@GitRjc
Copy link

GitRjc commented Jul 5, 2021

  • Compiler Used: Visual Studio 19
  • Operating System: Windows 10 64 bit
  • Architecture (ARM/x86/32bit/64bit/etc): Intel 64 bit

Expected Behavior : How to redirect ChaiScript "cout" and "print" to a Microsoft Windows 10 window?

Actual Behavior

Minimal Example to Reproduce Behavior

@totalgee
Copy link
Contributor

totalgee commented Jul 8, 2021

Are you compiling as a console application or regular Windows application? If a console application, the standard outputs should appear there already. If it's built as a Windows application, then one trick is to create a debugging console yourself, and redirect the standard inputs/outputs there. I think something like this should work in that case (not tested, but you can search and find examples on the web):

    ::AllocConsole();
    freopen( "CONIN$", "r", stdin );
    freopen( "CONOUT$", "w", stdout );
    freopen( "CONOUT$", "w", stderr );

@GitRjc
Copy link
Author

GitRjc commented Jul 10, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants