问题描述
我今天安装了 NetBeans 7.0.1 当我尝试在其中执行带有scanf"的 C 程序时,它给出了奇怪的错误
I've installed NetBeans 7.0.1 today When I try to execute C program with "scanf" in it it's giving strange errors
这是我写的:
它会一直运行,直到我在输出控制台中输入一些内容.
It keeps on running until I enter something in the output console.
进入后显示printf语句并显示RUN FAILED"
After entering its shows the printf statement and shows "RUN FAILED"
谁能告诉我我该怎么做才能做到这一点?
Can anybody tell me what should I do to make this right?
推荐答案
您的 printf 没有被刷新,因此它在程序结束之前不会显示.
Your printf is not getting flushed so it is not showing until the program ends.
您没有显式地从 main() 返回值,因此返回的是 scanf() 的结果,即 1 被解释为程序失败.
You are not returning a value from main() explicitly, so the result of scanf() is being returned, which is 1 which is interpreted as program failure.
这篇关于带有 scanf 的程序在 NetBeans 中无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!