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

问题描述

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

Why + 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

推荐答案

您需要按,然后使用 + 和然后再次.

You need to hit and then use + and then again.

或者,您也可以使用

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

09-05 18:50
查看更多