Thread: Building a program to access another execuatable

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    24

    Building a program to access another execuatable

    I'm using Turbo C 3.0

    I've been scratching my head trying to figure out how to write one program to use a seperate executable. I'm writing a game in which has to be compiled in a medium memory model, but I have a seperate program I need to use for the sound and it has to be compiled using a huge memory model. I'm figuring I need to pass some command line arguments, but being the newbie that I am I seemed to be stumped. Any help?

    Thanks ;-)

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    So do you need help with command line parameters? Or do you need help with calling an executable from another application?

    int main ( int argc, char **argv )

    argc will hold the number of arguments, including the executable name you've just run. Here is an example:

    Code:
    #include <stdio.h>
    int main ( int argc, char *argv[] ) /* same as char**argv */
    {
        int x;
        for( x = 0; x < argc; x++ )
        {
            printf( "Argument %d = '%s'.\n", argv[x] );
        }
        return 0;
    }
    That will show you how command line parameters work.

    Calling or invoking an executable from another is commonly done with system( ). Generally this isn't super as far as "safety" is concerned, but it will do the job.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    24

    thanks

    Thanks ;-) After checking out the link on system() (and after digging in my resource books) I was able to write this simple code to run my other program.


    #include <stdlib.h>
    #include <stdio.h>

    void main(){

    while(1){
    char *argv[1];
    argv[0] = "sound";
    system(argv[0]);
    }
    }

    Course, guess I should have added something to break that loop LOL

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    24

    Part 2

    K, now I want to pass further arguments to run my if else statements in the second program. Is this possible?

    For example, the first program will call to the second program to play 3 different sound files (each sound being "needed" in parts of the first program.....not all at once). How can I pass arguments from the first program to do this?

  5. #5
    Registered User
    Join Date
    Mar 2002
    Posts
    24

    and so....

    Since I've been only been able to work on this on the weekend...I haven't had sufficient time to figure this out on my own. Let me explain what I'm trying to do again.

    I want my first executable to call another program. The other program will play 5 different sound clips. How do I pass arguments to the second program to play the clip I need it to play?

    I've been screwing with this, but I can't get it to play the right clip when I need it. It keeps playing the same clip

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. Access Violation?
    By rwmarsh in forum C++ Programming
    Replies: 6
    Last Post: 05-04-2006, 10:56 AM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. I need some help with my program please.
    By agentxx04 in forum C Programming
    Replies: 9
    Last Post: 09-26-2004, 07:51 AM