Thread: Run Executible from inside main of other executible?

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    7

    Run Executible from inside main of other executible?

    HI,
    I was hoping someone could help me with how to link two executables. I have a executable that records data into two files. I then have another executable that parses those files into the information needed in a nice format. My plan is to convert this into one action. How do I run the parse executible from inside the 1st program?

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    For Windows, you can use ShellExecute or OpenProcess.
    But I find it just silly to have two apps. Make it into one app, if possible.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    There's an FAQ on how to run a program from within another program. http://faq.cprogramming.com/cgi-bin/...&id=1043284392

    I agree with Elysia, however -- you almost certainly don't want to do this, not the least because it might be quite difficult to communicate between the programs. If it's already set up so that you communicate with files, however, you could give it a shot.

    The simplest, and most portable, way to execute another program is with
    Code:
    system("program.exe");
    It might be slightly more secure (and perhaps less portable) if you use
    Code:
    system("./program.exe");
    but system() is inherently insecure. (And slow.) But any way you execute an external program is subject to security issues.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what to do with the main window
    By stallion in forum Windows Programming
    Replies: 2
    Last Post: 01-28-2003, 08:58 PM
  2. void main
    By Shadow in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 05-29-2002, 07:08 PM
  3. void main(), int main(), argc, argv[]????
    By Jonny M in forum C Programming
    Replies: 3
    Last Post: 03-06-2002, 09:12 AM
  4. why int main instead of void main?
    By Unregistered in forum C Programming
    Replies: 8
    Last Post: 10-26-2001, 10:49 PM
  5. void or int for main?:)
    By bigtamscot in forum C Programming
    Replies: 13
    Last Post: 09-27-2001, 03:11 AM