C语言实现求解最大值并以EOF结束问题

程序要实现的是输出所有数字中的最大值,并且输入以CTRL+Z结束。请问各位,为什么我这个代码运行起来按CTRL+Z无法结束呢

#define _CRT_SECURE_NO_WARNINGS 1
#include 
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;

}

这是运行结果

img

不是输入值为EOF,而是scanf函数的返回值为EOF

#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;
    while (scanf("%d", &k) != EOF)
    {
        if (k > i)
            i = k;
    }
    printf("the maximum is:%d", i);
}