我正在编写一个简单的代码来将文件的内容打印到标准输出。
当我使用这个:
while((c=fgetc(fp))!=EOF)putchar(c);
它像它应该的那样工作,但我想合并putchar
和fgetc
。所以我写了
while(putchar(fgetc(fp))!=EOF);
但这似乎不起作用。所以我检查了返回值putchar
RETURN VALUE
fputc(), putc() and putchar() return the character written as an
unsigned char cast to an int or EOF on error.
那么为什么它不起作用呢?