On 27 April 2018 at 15:16, akgrant43 <notifications@github.com> wrote:

Hi Vincent & Eliot,

Ugh. I didn't realize one couldn't use the same code in both :-(. I guess we have to test to find out what the context is and use dread in one and ReadConsole in the other.

I think it is worse than that. If I use the following test code in a
cygwin terminal:

#include <stdio.h>
#include <stdlib.h>

int main()
char	buf[1024];
char	*bufp;
int	cread;
int	count = 0;

bufp = &buf[0];
do {
    cread = fread(bufp, 1, 1, stdin);
    count += cread;
    bufp += cread;
    if (count > 16) break; }
while (cread > 0);
buf[count] = 0;

if (! feof(stdin))
    fprintf(stderr, "Error, not at end of file\n");

printf("%s\n", buf);
printf("Read %d characters\n", count);

And compile it with mingw:

$ i686-w64-mingw32-gcc -m32 consolestdio.c

It won't recognise EOF (Control-D).

Try Ctrl-Z
"In a non-Cygwin Windows program, Ctrl-Z on input triggers an end-of-file condition."

cheers -ben