Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Ctrl-Z does not trigger EOF?

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;
}

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

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

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

like image 762
Alex Avatar asked Jul 07 '15 06:07

Alex


1 Answers

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

or, you may also use F6

like image 154
BitFlip Avatar answered Sep 30 '22 21:09

BitFlip