Combine two program

Jan 13, 2015 at 9:04am
hai,

i tried to combine two programs into one..
in my first program it has one class object and main() and my second program it has only one main()

i want to combine these two into one

how to do this? can you help me?

Jan 13, 2015 at 9:12am
If these are 2 different executable files, A.exe and B.exe, then in for example A,

You can do a system call to run B.exe. In this way though, information is not passed from B to A or vice versa. The programs run as standalone.

If you really wish instead to do C.exe = A.exe + B.exe ???
http://stackoverflow.com/questions/2268515/merge-two-exe-files-into-one-programmatically

Good luck.
Last edited on Jan 13, 2015 at 9:17am
Jan 13, 2015 at 9:14am
A program performs a set of operations. A larger program does more operations.

We have no idea what operations you want your larger program to do, what your older programs do, nor how you want to combine them.

Please tell more details.
Jan 13, 2015 at 9:44am
Hai dear,

i need to execute first program and followed by second program..
i need result continuously
Jan 13, 2015 at 9:51am
i need to execute first program and followed by second program..
i need result continuously

In the same prompt?
Jan 13, 2015 at 9:57am
i am using NS-3 simulator script it has GCC compilor in ubuntu

i need same result in same program
Jan 13, 2015 at 10:01am
hai dear,

my first program like this

#headerfile

class {
}

int main ()
{
}

my second program like this

#header file

int main()
{
}



so i need to combine second program main function into first program
i need result for that program?
Jan 13, 2015 at 10:29am
hai,,

can anyone help me?
Jan 13, 2015 at 11:29am
i need to execute first program and followed by second program.

This implies that the output of the first is stored and used as input to the second. Is that so?

i need result continuously

What do you mean by that?


Given:
1
2
3
4
5
// A
int main() {
  std::cout << "Hello\n";
  return 0;
}

1
2
3
4
5
6
7
// B
int main() {
  std::string word;
  std::cin >> word;
  std::cout << word << " world\n";
  return 0;
}

You could
# A | B
Hello world
#

But since you have the source, you can copy and adapt the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
// C
int main() {
  // A
  std::ostringstream aout2bin;
  aout2bin << "Hello\n";

  // B
  std::string word;
  aout2bin >> word;
  std::cout << word << " world\n";

  return 0;
}

And then condense:
1
2
3
4
5
// C'
int main() {
  std::cout << "Hello world\n";
  return 0;
}

Jan 14, 2015 at 3:44am
Hai dear,

Thank for ur reply..

I need to add second program function into first program main function

its like

my first program

class{
}
int main{

// here i need to add second program functions only because other things are same//

}

and need one output?

can you help me?

Jan 14, 2015 at 9:41am
I thought that I already did. I did show example programs A and B and then program C that does both operations. Didn't that make the concept clear?

In order to "add second program functions into first program" you have to add the second program functions into the first program. Only you know what those functions are and do, and therefore at this point only you can adapt the functions as necessary, just like I did not merely copy-paste A and B into C.
Jan 14, 2015 at 11:01am
I'll repost what I wrote in your other thread:

It's almost certainly possible. However, you've shown us no real code, and told us nothing about what your programs do, nor about how you wish to combine their functionality. How on earth do you expect us to be able to help you?
Topic archived. No new replies allowed.