2014-11-01 55 views
0

我刚刚开始在Eclipse上运行,我似乎遇到了printf()语句的问题。我运行了一个在Notepad ++中工作的基本代码,但在Eclipse中似乎没有这样做。编译并运行程序后,下面的控制台中似乎没有打印任何内容。我的代码,IDE或其他东西有问题吗?printf不能在eclipse中的控制台中打印c

#include<stdio.h> 


int main (void) 
{ 
    printf("Hello world"); 
    fflush(stdout); 

    return 0; 
} 
+0

在哪个操作系统上使用哪个编译器? Eclipse只是一个光荣的编辑器。 – 2014-11-01 18:11:52

+0

版本:Juno Service Release 1.操作系统:Windows 7 – QuayShawn 2014-11-01 18:28:20

+0

但是用哪个编译器?尝试在命令行上运行你的编译器(Eclipse在内部执行)。 – 2014-11-01 18:31:15

回答

2

此链接可能会帮助

Why does printf not flush after the call unless a newline is in the format string?

尝试在printf的添加 '\ n'。

printf("Hello world\n"); 
+1

感谢您的建议,但仍然没有运气。即使添加了\ n,控制台在运行后仍然是空的。 – QuayShawn 2014-11-01 18:29:37

+0

setvbuf(stdout,NULL,_IONBF,0);如果您仍然有问题,请尝试在printf之前添加此项.http://stackoverflow.com/questions/13035075/printf-not-printing-on-console – Gopi 2014-11-02 17:05:49