I have an application that need to send command to cmd and then get the ouput back (capturing the output). How can this be accomplished using C++ without using any MS Windows specific API? Is there a way that this may be done to be cross platform (for linux terminals for example)?. By the way i’m on win XP SP3.
I actually mean redirecting the input/output. For example, run the command “make” on cmd and then in case of error capturing the error message (redirecting to my application).
As mentioned: if you can avoid launching child processes in your program and instead fit into the broader “toolbox metaphor,” that can often be better…
http://en.wikipedia.org/wiki/Unix_philosophy
But if that’s not a fit for your project, check out Boost.Process.
Also: if you’re using Qt (which is good to look at in any case) there is also QProcess.