Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Win32: writing to STDOUT

richardduncan
Beginner
711 Views
I am developing a Win32 application with some basic command-line functionality; for example, the program has available a "--help" option that prints a brief help message then exits, without calling the GUI.

Clearly, using WRITE(UNIT=6,...) for writing to standard output does not work. When called from a regular WinXP "Command Prompt" terminal, e.g., "myprog.exe --help", nothing is printed in the terminal; however, when I redirect the output using

myprog.exe --help > help.out,

the file help.out is populated with the desired text. Furthermore, when executing "myprog --help" through a linux-emulator terminator (Cygwin), all works as expected.

Attempting to resolve this, I have tried using SetStdHandle; however, my implentation of this has been fruitless. Surely there is something fundamental here that I am missing.

CVF 6.6C on WinXP

Thanks a bunch,

Richard
0 Kudos
1 Reply
Steven_L_Intel1
Employee
711 Views
Win32 apps don't have a console associated with them by default. You can create one by calling AllocConsole before you do the WRITE.

You may also want to consider using MessageBox to display the help text. Create a string with the text - embed CR-LF pairs as line separators, and terminate with a NUL.
0 Kudos
Reply