简体   繁体   中英

How do I call a program or code which has main in debug mode?

I have a CPP program (let's call it program 1) which calls another CPP program (Program 2). This Program2 is built in debug mode. That is:

   int main(int argc, char** argv) {
    ///Function body#
     eerot[0] = atof(argv[1]); 
eerot[1] = atof(argv[2]); 
eerot[2] = atof(argv[3]); 
eetrans[0] = atof(argv[4]); //Exception thrown here due to memory clash
     ///Continue
    }

The above fragment of the code describes the structure of my main program in program2. Program2 has neither execution error nor does it throw any exception. Now I want to call this main function of program2 from program1 but I am stuck with the double pointer variable. Because the argv variable is double pointer, and even though I was able to create a string, double reference it and pass it as parameter to program2, I get exceptions. There is no compile error. All the appropriate headers are perfectly defined.

I cannot edit program2 since it was developed by some other team and it is quite difficult to follow. I have changed the name of main function of program 2(say to "calculate()") and called that from main of program1. I have also included directories and header files appropriately to make all functions and classes of program2 visible in program1. Right now only thing I am stuck is with the double pointer argv variable. How can I pass the parameters which I have to pass via the command prompt be passed via another program?

Note that the parameters we pass in command prompt for program2 is of type double. I tried to use arrays but I keep getting exceptions thrown at me. Let me know anything that comes to your mind when trying to solve the problem.

I believe the problem is the triple pointer in the main() declaration. You probably meant:

int main(int argc, char** argv) {

or

int main(int argc, char* argv[]) {

you want either char **argv ... OR char *argv[], NOT char **argv[]

both of the above are pointers to arrays. What you have is a pointer to a 2D array basically so the way you are accessing the elements ends up exceeding the number of array elements.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM