I'm having problems with sending the input to another program... Here is what I'm supposed to do. Ask for nth number in the fibonacci sequence. The program will call another program (fibonacci.exe) genterate the nth number and pass back the information to the parent process, and display all numbers of the fibonacci seq up to the users number. I have no problems running the fibonacci program, it is passing the input from the user and returning it. Here is what I have so far:
#include <stdio.h>
#include <Windows.h>
#include <iostream>
using namespace std;
int main(VOID)
{
STARTUPINFOA si;
PROCESS_INFORMATION pi;
//allocate memory
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
int parameter1=0;
cout << "Enter a number: " << endl;
cin >> parameter1;
//create child process
if (!CreateProcessA(NULL, //use command line
"Desktop\ConsoleApplication1.exe", //command line
parameter1, //don't inherit process handle
NULL, //don't inherit thread handle
FALSE, //disable handle inheritance
0, //no creation flags
NULL, //use parent's environment block
NULL, //use parent's existing directory
&si,
&pi))
{
cout << stderr << "Create Process Failed";
system("PAUSE");
return -1;
}
//parent will wait for the child to complete
WaitForSingleObject(pi.hProcess, INFINITE);
cout << "Child Complete";
system("PAUSE");
//close handles
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
Thanks for any and all help.