Output and input from console window?

T

Teis Draiby

I am working on a Win32 program with an additional console window to output
messages. I also want to type commands in the console window. Is there any
common way to achieve that?
For example how do I output messages while the console is listning for
command inputs?

I'm looking forward for your answer with great anticipation
 
C

Carl Daniel [VC++ MVP]

Teis said:
I am working on a Win32 program with an additional console window to
output messages. I also want to type commands in the console window.
Is there any common way to achieve that?

Of course - just like you would with a pure console program. See

http://support.microsoft.com/default.aspx?scid=kb;en-us;105305

for information on how to connect a console to stdin and stdout from within
a GUI program.
For example how do I output messages while the console is listning for
command inputs?

If you want to both wait for input and write output you need to use multiple
threads - one for reading and one for writing. If your GUI is writing to
the console (debug log messages, for example), you probably want to create
another dedicated thread that does the console input and processes the
command that you enter.

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top