2014-02-08 109 views
0

该程序为什么不打印任何输出。Printf不打印输出

#include<stdio.h> 

int main() 
{ 
    int c, i, nwhite, nother; 
    nwhite = nother = 0; 
    int ndigit[10]; 

    for(i=0; i<10; ++i) 
     ndigit[i] = 0; 

    while((c = getchar()) != EOF) 
     if(c >= '0' && c <= '9') 
      ++ndigit[c-'0']; 
     else if(c == ' ' || c == '\n' || c == '\t') 
      ++nwhite; 
     else 
      ++nother; 

    for(i=0; i<10; ++i) 
     printf("%d\n",ndigit[i]); 
    printf("%d - %d", nwhite, nother); 
} 

输入:它继续获得高达EOF输入。

+0

所以,你试图输入一些输入和'EOF'? –

+0

http://barbsbitsnbytes.com/pics/hammerd.jpg –

+0

@SakthiKumar是的。 EOF是-1,我试过了,但它仍然不起作用。 – ajkumar25

回答

1

试试这个:

for(i=0; i<10; ++i) 
     printf("%i\n",ndigit[i]); 
    printf("%i - %i", nwhite, nother); 
+0

OP有什么问题? – chris

+0

它仍然得到输入。 – ajkumar25

+0

@rcomp尝试输入“Ctrl + D”,这是输入 –