about c語言問題

2008-06-02 10:03 am
我compile c source file 做 .exe檔
跟住係winxp下開..但input 完 data 後 自動熄左(唔係程式錯)
請問...原因何在..?
謝謝~

回答 (2)

2008-06-02 8:41 pm
{int a, b;

printf("A, B=> ");

scanf("%d %d", &a, &b);

if(a

b) printf("%d>%d\n", a, b);

if(a==b) printf("%d=%d\n", a, b);

return 0;}

我的programme..
2008-06-02 1:37 pm
This happens very often with Dev-C++.
When the program terminates, it closes the console window (black background) automatically.
All you have to do is to add a command that request input from the keyboard, such as:

int main(...)
{
char anything[10];
.... your program here
printf("Press enter to terminate console...");
gets(anything);
return 0;
}

This way, the console will await input before quitting.


收錄日期: 2021-04-13 15:38:23
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20080602000051KK00259

檢視 Wayback Machine 備份