【发布时间】:2015-05-22 14:19:57
【问题描述】:
问题
验证表达式
getchar() != EOF是0或1。
接近
我试图编写一个程序,它首先接受EOF 以外的输入,因此将打印值1。接下来它将以EOF 作为输入并打印0。
/* Program to verify that the value of the expression getchar() != EOF is 0 or 1 */
#include <stdio.h>
int main()
{
printf("Inputting something other than EOF, value of the expression is %d\n", getchar() != EOF);
printf("Inputting EOF, value of the expression is %d\n", getchar() != EOF);
printf("It is verified that the expression getchar() != EOF is 0 or 1.\n");
return 0;
}`
问题:
但是当我给出输入时,它不会打印第一行并等待下一个输入。它直接打印所有行。如何让第二行接受下一个输入?
【问题讨论】: