SUMMARY: console on demand?

Jim Roy
Mon Aug 16 12:00:00 GMT 1999

Thanks all.

My original question was how to avoid getting a window if you
don't need one.

Compiling with the -mwindows flag solved that.
"Console" mode programs have a console window attached by default,
but "GUI" mode programs do not.

That led to a second problem.  How to use printf() and it's relatives
with a console window in a GUI mode program, when you DO need to
interact with the user.

A chain of calls like:

> handleout = GetStdHandle (STD_OUTPUT_HANDLE);
> fdout = _open_osfhandle(handleout);
> fpin = fdopen(fdout, "w");
> fprintf( fpin, "blurf");

solves the problem.

Tol suggests a more direct method, using freopen(), but it does
not seem to work for me.  Perhaps, as he suggests it works with
msvcrt, but not with crtdll.

Thanks again,

Jim Roy                      voice  541 757 7231
Sys. Admin.                  fax    541 757 7331
NW Geophysical Assoc.
Corvallis Or. US

Want to unsubscribe from this list?
Send a message to

More information about the Cygwin mailing list