如何一起实现两个不同的源代码? [英] How do I implement two different source codes together?

查看:237
本文介绍了如何一起实现两个不同的源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个独立的源代码,我想像第一个屏幕一样实现它们,然后在turbo c ++中实现另一个屏幕。我该怎么做?这是我想要与我的第二个程序/代码互连的第一个部分/程序。



#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,日记管理系统);

settextstyle(3,0,2);

outtextxy(40,400,按Enter继续 );

getch();

closegraph();

}



//现在我的第二部分//



clrscr();

做{

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();

}

而(1);

}



我尝试了什么:



当我尝试同时运行这两个程序时第一部分运行而第二部分没有。有什么方法我可以在进入后同时运行这两个程序吗?

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?

推荐答案

如果你的意思是同时在真正做事而不是做一件事,然后做完另一件事后完成比复杂 - 你需要看看设置单独的线程来运行每个块的代码。如果我没记错的话,Turbo C ++没有任何线程支持 - 它已经很老了!



如果你的意思是运行一点,然后运行另一个它已完成,那么你可能需要再次调用
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.


你可以通过使用主函数中的开始菜单来完成它,这样你就可以选择使用哪个子程序。



You can do it by using a start menu in the main-function, so you can choose which subroutine to use.

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;
  }
}


这篇关于如何一起实现两个不同的源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆