Search code examples
c++c++builderbinutils

Win application calling a DOS command


How can I call a DOS command and retrieve its output from a windows program that I will program in C/C++?

My prog would be like a "front-end" for the DOS command.


Solution

  • The easiest way (IMHO) is to spawn the DOS application as a new process and connect your standard output to its standard input and its standard output and standard error to your standard input, using pipes. Then you can communicate with the child process by simply writing to standard out and get output from the child by reading from standard in.