Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have two separate source codes and I want to implement them together like the first screen and then another screen in turbo c++. how do I do that?this is the first part/program that i want to interconnect with my second program/code.

#include<stdio.h>
#include<string.h>
#include<stdlib>
#include<graphics>
void main(){
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\TURBOC3\\BGI");
{
setbkcolor(5);
setfillstyle(CLOSE_DOT_FILL,WHITE);
bar(100,100,200,200);
setfillstyle(CLOSE_DOT_FILL,WHITE);
bar(200,200,400,400);
settextstyle(3,0,5);
outtextxy(40,200,"diary management system");
settextstyle(3,0,2);
outtextxy(40,400,"press enter to continue");
getch();
closegraph();
}

//now my second part//

clrscr();
do{
setbkcolor(12);
setfillstyle(CLOSE_DOT_FILL,WHITE");
bar(100,100,200,200);
setfillstyle(CLOSE_DOT_FILL,WHITE");
bar(200,200,400,400);
settextstyle(3,0,5);
outtextxy(40,100,"CREATED BY:");
settextstyle(3,0,3);
outtextxy(40,200,"MICHELLE ");
settextstyle(3,0,3);
outtextxy(40,279,"IFRAH");
getch();
closegraph();
}
while(1);
}

What I have tried:

when i try to run both of these programs together only the first part runs while the second part doesn't.is there any way I can run both of these programs at the same time after entering?
Posted
Updated 24-Feb-18 7:15am

If you mean "at the same time" as in "genuinely doing things together" instead of "doing one thing, then doing the other after it finishes" than that complex - you would need to look at setting up separate threads to run each "chunk" of code. And if I recall correctly, Turbo C++ doesn't have any threading support - it is pretty old!

If you mean "run one bit, then run the other when it's finished", then you probably need to call
initgraph
again, or not close it in the first block of code.
 
Share this answer
 
Comments
CPallini 24-Feb-18 17:08pm    
"you probably need to call initgraph..."
Most likely, 5.
You can do it by using a start menu in the main-function, so you can choose which subroutine to use.

C++
char c = 's';//some value

while( c = 'x' {
  // make some screen output to explain what to do 
  c = getchar();

  switch( c )
  {
    case '1':
     subRoutine1();
     break;

    case '2':
     subRoutine2();
     break;

    case 'x':
     break;
  }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900