0

I am having a project. I need to link two separate programs, one the main activity and the other the user data with each other. I have to use Turbo C++ Compiler only.

2 Answers2

1

I think you should have a look in the header file process.h

It contains several functions to start other processes and I guess that is what you want to do.

https://en.wikipedia.org/wiki/Process.h

That said, it is sad that you in this time and age must work with an antiquated compiler when there are so many good, free alternatives.

EDIT:

So the above advice is for the situation that you have two .exe files and want to call one exe from the other. There are of course better ways to do this if you have both source codes. You can e.g. create a DLL and dynamically load the DLL with the .exe or you can create a statically linked .LIB file and link it to the exe.

AndersK
  • 35,813
  • 6
  • 60
  • 86
  • I did it. I first used the process.h header and included the other file as #include<(filedirectory\name.cpp)> and then used spawnl function to start the process – Utkaarsh Saha Nov 02 '19 at 06:29
  • I think what you need to do is compile the other program separately creating a separate .exe file, then call that .exe from your first program. If you include the .cpp then there is no need to use process.h since you are in the same .exe – AndersK Nov 02 '19 at 06:33
  • @Anders if this answered your question you should accept it as solution (check the checker near the votes counter) – Spektre Nov 04 '19 at 09:49
  • 1
    Advice like "use a DLL" presumes that you have something as modern as Windows 1.0 from 1985. But even that luxury appears to excluded, as the target is ancient MS-DOS. – MSalters Nov 04 '19 at 11:31
  • @MSalters I worked with Windows 1.0 back in 1988 which ran on top of DOS. Dont remember if there were DLLs back then to be honest. :) – AndersK Nov 06 '19 at 06:08
0

Fro separate runs like you described in your comment:

rename the main functions in both programs to for example main1,main2 and then include their sources in your final program:

#include "source1.cpp"
#include "source2.cpp"
void main()
 {
 ...
 if (option==1) main1();
 if (option==2) main2();
 }

In case of naming conflicts you can use namespace or rename the conflicting variables/constants/macros/functions.

If you need that both programs run at the same time instead you would need to merge the two mains into single one which is not that easy and without seeing the code architecture its unanswerable... Such task either interleaves the calls and logic of the two programs or implement sort of multi-threading using PIT ISR as timer.

Spektre
  • 49,595
  • 11
  • 110
  • 380