Unfortunately you did not mention which OS you are running on.
I'll try with Windows anyway:
The function you are looking for is CreateProcess()
BOOL WINAPI CreateProcess(
TEXT("<path and filename of your application>"),
TEXT("<CommandLine parameters>"),
...
);
You pass the name, path and command lines to your program to run.
The redirection of the console input and output is done by setting the flag STARTF_USESTDHANDLES in dwFlags and filling the appropriate members in the STARTUPINFO structure (underlined below).
typedef struct _STARTUPINFO {
DWORD cb;
LPTSTR lpReserved;
LPTSTR lpDesktop;
LPTSTR lpTitle;
DWORD dwX;
DWORD dwY;
DWORD dwXSize;
DWORD dwYSize;
DWORD dwXCountChars;
DWORD dwYCountChars;
DWORD dwFillAttribute;
DWORD dwFlags;
WORD wShowWindow;
WORD cbReserved2;
LPBYTE lpReserved2;
HANDLE hStdInput;
HANDLE hStdOutput;
HANDLE hStdError;
} STARTUPINFO, *LPSTARTUPINFO;
Here the links to the MSDN documentation for more details:
CreateProcess():
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx[
^]
The STARTUPINFO structure:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686331(v=vs.85).aspx[
^]
If this is not the intended OS, please let us know.
Good luck with your project!
Steve