无法看到C程序输出 [英] Unable to see the C program output
本文介绍了无法看到C程序输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我输入了一个使用dos框和Turbo C编译器在C中计算SI的程序。
我的程序 被编译但是没有显示输出。< br $> b $ b
我尝试过:
我还输入了一个程序显示'你好世界'。它完美地显示了输出。但是当我尝试执行SI程序时,输出会在闪烁时打开和关闭,而不显示输出。
I have typed a program to calculate SI in C using dos box and Turbo C compiler.
My program gets compiled but it doesn't show the output.
What I have tried:
I have also typed a program to show 'hello world'. it shows the output perfectly. but when i try to execute the SI program , the output opens and closes in a blink, without showing the output.
推荐答案
问题是当你运行控制台时应用程序,它期望来自用户的输入 - 如果它没有得到它,它不会等待 - 它关闭,控制台窗口也关闭。结果,你在屏幕上看不到任何东西,因为它不存在足够长的时间。
所有你要做的就是强制它在关闭之前等待你: br />
The problem is that when you run a console app, it expects input from the user - and if it doesn't get it, it doesn't wait around - it closes and the console window is closed as well. As a result, you can't see anything on the screen because it just isn't there for long enough.
All you have to do is "force" it to wait for you before closing:
void main()
{
printf("Hello World!\n");
getchar();
}
这篇关于无法看到C程序输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文