开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
GCC
问题(Question):
执行后,无法测试出是否有newline, tabs, blanks,结果都为0
DOS接口的EOF指令除了control-z 还有?
喂入的资料(Input):
I like programming and surfing on the ptt.
All the output are zeros.
Please help me.
^z
预期的正确结果(Expected Output):
newlines:3
blanks:12
tabs:1
程式码(Code):(请善用置底文网页, 记得排版)
int main (void)
{
int c, newlines, blanks, tabs;
int done = 0;
newlines = 0;
blanks = 0;
tabs = 0;
while( c = getchar() != EOF)
{
if ( c == '\n')
newlines++;
if ( c == ' ')
++blanks;
if ( c == '\t')
++tabs;
}
printf ("newlines:%d\nblanks:%d\ntabs:%d\n", newlines, blanks, tabs);
return 0;
}