How to write text to command prompt console windows?

  • Thread starter Thread starter Steven
  • Start date Start date
S

Steven

I am using VC++ 6.0 to build a windows based application, however, my
application allows user to input command arguments in the dos prompt
windows. I want to have a warning message for user if they have input the
wrong arguments. How can I write text to the dos prompt windows if user
input the wrong arguments?

Thanks in advance.

Steven.
 
I am using VC++ 6.0 to build a windows based application, however, my
application allows user to input command arguments in the dos prompt
windows. I want to have a warning message for user if they have input the
wrong arguments. How can I write text to the dos prompt windows if user
input the wrong arguments?

When your app starts, validate the arguments in the argument list (called
argv typically)
If the arguments are OK, proceed with your app. If they aren't, print an
appropriate message to the console, with printf, fprints, or cout.
 
Bruno said:
When your app starts, validate the arguments in the argument list (called
argv typically)
If the arguments are OK, proceed with your app. If they aren't, print an
appropriate message to the console, with printf, fprints, or cout.

OTOH, if they start the application with an icon (and there isn't a DOS command
window) you have to reflect the error in a messagebox anyway so why not just do
it that way for both cases?

/steveA
 
Use AllocConsole() to attach the stdin, stdout, stderr handles so that
printf(), fprintf(stderr,...) etc. will show up for gui apps.
 
Back
Top