2014-02-08 108 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」,這是輸入 –