C and C++
Hi! I am Karthik I am programming in C and C++. I want to know how to input data from one executable file(whose code is available) to other executable file(whose code is not available).
Please mention the OS to be used.
Web Development
Hi! I am Karthik I am programming in C and C++. I want to know how to input data from one executable file(whose code is available) to other executable file(whose code is not available).
Please mention the OS to be used.
Sorry, we'll need more info in order to help you. Start by defining what you mean by "input data from one..."
Ralph
That is for example if I have got 2 'C' or 'C++' programs 'a.c'(whose code is present) and 'b.c'( whose executable 'b.exe' is present and not the code). Then I want to give some data required as input by 'b.c' executable file(i.e., input required bya 'scanf()' statement in its code for characters, numericals..etc.) then this has to be given by 'a.exe' executable file which gives the required output as input to' 'b.exe' executable file.
In the whole one program 'a.c' has to invoke another file 'b.exe'.
You may well need to go back to some old C type functions to achieve this. The one I am thinking of is "spawn", and you would have to look up the manula to find out specifics of the implementation. The other you might bear in mind which does a similar job is "exec".
Both of these start a new process, and use a command line construct to start the process. For example spawn( mode, command, arg0, .... ). If you run b.exe as expecting input from the keyboard as per scanf, try outputting the datato a file or string and redirecting stadin from the console to that file or string.
e.g. "b.exe << data.txt"
Your code will probably look something like:
spawn(mode, "b.exe << data.txt")
This will need some experimentation to get right, and I would find out exactly how to get the command line working for the called program before trying to put it into code.
Note also that this method really assumes that there is no return data from the called program. The return result from the function is the execution status code of the called program, and hopefully that will always be zero for you.
Hope this helps,
Darryl
This discussion is closed to new replies.
Sort by Trending