Miracle C output問題

2009-03-22 1:04 am
我想問點解我寫完個program...
如果我個program係有叫user input D野落個program道既就run到...
I MEAN我用printf,scanf個D program先run道...

如果我寫個Program係就咁Print D野出黎,冇input既...
run到但冇字出...

點解???

勁急我要趕住交功課...

回答 (1)

2009-03-22 11:13 am
✔ 最佳答案
There is no problem. If you are compiling with most C compilers, the output window is closed at the end of the execution, which is normally quite short, to the extent that you do not see the output.
All you need to do is to insert at the end of the program a statement that requires user input, like scanf(...), or system("pause");
This will halt the exit of the screen and allows you to view the output.

2009-03-23 04:41:51 補充:
With the information that you gave, it is hard to pin-point the problem, because I don't get to know if your window disappeared or not.
A normal compiler should print something with:
#include stdio...
void main(){printf("HELLO!\n"); system("pause");}

2009-03-23 04:42:01 補充:
You could also try forcing to display using:
fflush(stdout);
after the print statement.
If that still does not work, you may want to check your compiler or configurations.
Finally, check if you have a loop in your program so the print statement never got executed.


收錄日期: 2021-04-13 16:30:59
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20090321000051KK01131

檢視 Wayback Machine 備份