January 10th, 2014, 04:02 PM
Open External application
How can I send information and receive from external command prompt from my program.
I want to run an external command prompt, a code that's is not mine, to send information to this command prompt, then make my program hit enter at
the command prompt and then receive back information from the command prompt.
Thanks in advanced.
January 10th, 2014, 04:31 PM
Not sure what you mean.
There's popen() which opens a command prompt and runs the program that you tell it to run. It returns pipe that's tied to the stdin and stdout files of that program and that you can use to communicate with the program. Specifically, popen() returns a FILE*, just like fopen() does, which you can then read from and write to just as you would with a disk file.
Is that what you are looking for?
January 11th, 2014, 01:13 AM
January 12th, 2014, 11:37 AM
I will try to explain my self better
This is what the external executable file do
I have a program the's when I run it the program open a cmd (Command Prompt )
and I can enter manually variables, press enter the program calculate for me something and then present on
the cmd the calculated variables.
how I want to use the external executable file
my question is how to write a code in C that's will open this program then send every time different variables and then receive back from the program the calculated variables??
thanks in advanced
January 12th, 2014, 11:54 AM
I already told you how! If popen() doesn't do what you need, then you need to explain why it doesn't and be more specific about your needs.
Originally Posted by yaron
January 12th, 2014, 01:40 PM
I have include #include <stdio.h>
Originally Posted by dwise1_aol
and it's say to me about the popen "missing prototype. (require function prototypes build option is enabled.)"
January 12th, 2014, 02:29 PM
What operating system? I've used it both in a Windows/DOS environment and under Linux, so I know it's supported in both.
What compiler? If you're using something really ancient, then there's no telling what it will or won't support.
Third option: how are you trying to use it? Copy and paste your short complete and compilable program so we can test it. Use code tags.