Skip to content

Instantly share code, notes, and snippets.

@dantswain
Created March 5, 2012 22:22
Show Gist options
  • Save dantswain/1981581 to your computer and use it in GitHub Desktop.
Save dantswain/1981581 to your computer and use it in GitHub Desktop.
how to get a stdout/stderr console in windows
if(AllocConsole())
{
freopen("CONOUT$", "wt", stdout);
freopen("CONOUT$", "wt", stderr);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
fprintf(stdout, "\n");
fprintf(stdout, " stdout/stderr Console\n");
fprintf(stdout, "\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment