views:

47

answers:

2

I need to control a program in c++ (windows), I need to call it, then pass data to it as I collect it, finally after a certain command that program will use that data.

I need to open the prog.exe and then line by line or value by value supply it information, it works manually through cmd.

I have tried system() but this will stop after I open the program.

I need something like this.

//call it
prog.exe
//add data
DataStart
Data 1 [2 34 454 5]//etc
DataEnd //the program will take it from here.

all being passed though command line

thanks.

+1  A: 

There are different ways you could do this - if your program needs to execute part of the way through your code before getting the data as input, you can just use standard input, and prompt the user to type the data. If you want to use variable values for the input, but you will know them before execution, you can pass the information as command line arguments, where you will execute like so

prog.exe 1 2 3

and your program will access the data via argv[i] where i corresponds to each command line argument.

roviuser
sorry if i have put this reply in the wrong section.I do not know any of the values so i cannot parze the command line.by calling the program, it starts in the shell, it will then except user inputs as its variables etc. the program accepting these inputs is not minei am wanting to input these variables, however then need to be queried each time. i need to stat the prog and leave access to it so i can add this data as it is quried.
t_s
A: 

thanks sarnold, got it working through the link you provided by creating a pipe using _popen().

Much Appreciated.

Cheers!

t_s