程序要实现的是输出所有数字中的最大值,并且输入以CTRL+Z结束。请问各位,为什么我这个代码运行起来按CTRL+Z无法结束呢
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
printf("plese enter the numbers to find the maximum(end with 'ctrl + z'):\n");
int i = 0;
int k;
scanf("%d", &i);
while (i != EOF)
{
scanf("%d", &k);
if (k > i)
{
i = k;
}
if (k == EOF)
{
printf("the maximum is:%d", i);
break;
}
}
return 0;
}
这是运行结果