hello. I am writing a program that will solve a type of min. spanning tree problem. i have 2 different algorithms that I've gotten working in two separate .cpp files i've named kruskels.cpp and prims.cpp.

my question is this:

each file takes the following command line to run it . time ./FILENAME INPUTFILE FACTOR

i would like to make a program that, depending on what inputfile is entered, will run either kruskels.cpp or prims.cpp. how can i do this?

this program must pass those command line arguments to kruskels or prims. each file (kruskels.cpp and prims.cpp) are designed to be run using those command line arugments (so they take in INPUTFILE and FACTOR as variables to do file io).

Rename each main to be

int kruskels_main( int argc, char *argv[] );
int prims_main( int argc, char *argv[] );

The driver.cpp then becomes (with a bit of fluff for choices)

int main ( int argc, char *argv[] ) {
    return  kruskels_main( argc, argv );
}

will this work if both programs have already been compiled?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.