在c \ c ++ ide eclipse中不起作用? [英] do-while did not work in c\c++ ide eclipse?

查看:178
本文介绍了在c \ c ++ ide eclipse中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int a=100;
    do{
        printf("insert a");
        scanf("%d",&a);
    }while(a<10);
    return (0);
}



我在Eclipse C \ C ++ IDE中编写了此代码,但没有用.

代码块的语言已更改[/编辑]



I write this code in eclipse C\C++ IDE but did not work.

Language of code block changed[/Edit]

推荐答案

不正确.它实际上执行了一些操作:总是执行循环的第一次迭代,至少有一个插入a"输出到控制台(如果有的话;取决于项目配置),其他则取决于您输入的a的值.当然,该代码几乎没有意义-您需要告诉我们您想首先实现什么.

—SA
Not true. It actually does something: first iteration of the loop is always executed, at least one "insert a" outputs to console (if one is available; it depends on project configuration), others depend on what value for a you are entering. Of course, the code makes little to no sense — you need tell us what did you want to achieve first.

—SA


如果您正在研究Windows,那么您可能会对此感兴趣: [
If you are working on Windows then this may interest you: "Eclipse console does not show output on Windows"[^].


我没有刷新.

这有效:

i was missing a flush.

This works:

...
printf("insert a");
fflush(stdout);
scanf("%d",&a);
...


另请参见"[已解决]控制台中无输出"
http://www.eclipse.org/forums/index.php/t/156519/ [ ^ ]


See also "[SOLVED] No Output in Console"
http://www.eclipse.org/forums/index.php/t/156519/[^]


这篇关于在c \ c ++ ide eclipse中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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