为什么Ctrl-Z不会触发EOF? [英] Why Ctrl-Z does not trigger EOF?

查看:82
本文介绍了为什么Ctrl-Z不会触发EOF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 Ctrl + Z 不会触发循环在以下小程序上完成?

Why Ctrl+Z does not trigger the loop to finish on the following small program?

#include <stdio.h>

main()
{
    int c;
    while ((c = getchar()) != EOF)
    {
        //nothing 
    }

    return 0;
}

如果我输入: test ^ ZEnter ,它不会跳出循环.

If I enter: test^ZEnter, it does not get out of the loop.

我在(此处此处),但无人解释Windows下的C(不是C ++).

I found related questions around (here and here) but none to explain it for C (not C++) under Windows.

注意:我在Windows 8.1上使用Visual Studio 2015 PRE

Note: I use Visual Studio 2015 PRE on a windows 8.1

推荐答案

您需要按 Enter ,然后使用 ctrl + Z 和然后再次输入.

You need to hit Enter and then use ctrl+Z and then Enter again.

或者,您也可以使用 F6

这篇关于为什么Ctrl-Z不会触发EOF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆