How to modify external programs

Is it possible to write a program where its function is to incorporate itself permanently into that of another program's
ex. Prog 1 "hello world"
Prog 2 "some other function"

Prog 2 "some other function + hello world"
delete prog 1

result prog 2: that performs both tasks.

is this possible, and if so, can someone point me towards how I would go about accomplishing this task ?
It is possible, but it is way above your skill level, alas.

You could just execute the first program from the second program:

1
2
3
4
5
6
7
8
9
10
#include <cstdlib>
#include <iostream>
using namespace std;

int main()
{
  cout << "some other function + ";
  system( "hello.exe" );
  return 0;
}

You still have two programs, of course...
Please at least point me towards its general direction. The point of this is to incorporate both programs into program two without program two's prior knowledge, while only using program one.

EDIT: I noticed this was posted in beginners, this was an accident I excuse myself.

EVEN MORE EDIT:
okay let me clarify myself
Lets say prog 2 is something super simple like
int main(){
cout << "hello world";
Sleep(500);}

how do i get prog one to inject code to it that will make it say
int main(){
cout << "hello world";
Sleep(500);
cout << "SECONDLINE";
Sleep(500);}
Last edited on
Topic archived. No new replies allowed.