#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    3
    Rep Power
    0

    Open External application


    Please Help!!

    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.
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,162
    Rep Power
    2222
    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?
  4. #3
  5. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,387
    Rep Power
    1871
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    3
    Rep Power
    0

    I will try to explain my self better


    Hay
    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
  8. #5
  9. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,162
    Rep Power
    2222
    Originally Posted by yaron
    Hay
    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
    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.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    3
    Rep Power
    0
    Originally Posted by dwise1_aol
    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.
    I have include #include <stdio.h>
    and it's say to me about the popen "missing prototype. (require function prototypes build option is enabled.)"
  12. #7
  13. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,162
    Rep Power
    2222
    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.

IMN logo majestic logo threadwatch logo seochat tools logo