
printf to allocated console
Quote:
> If I create a console app using "/subsystem:console" as
> linker setting, I can use printf to output text to the
> console.
> However, if I use "/subsystem:windows" and then call
> AllocConsole(), printf doesn't output text to the run-time
> allocated console.
> What's the solution?
AllocConsole();
int hCrt = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE),_O_TEXT);
FILE * hf = _fdopen( hCrt, "w" );
*stdout = *hf;
setvbuf( stdout, NULL, _IONBF, 0 );
// Luc K