How can I send EOF to windows git bash terminal?

581 views
Skip to first unread message

Thane Michael

unread,
Aug 12, 2016, 10:48:10 AM8/12/16
to git-for-windows
I'm running this C program (from the C programming by K&R);

#include <stdio.h>
main
(){
double nc;
for(nc = 0; getchar() != EOF; ++nc);
printf
("%.0f\n", nc);
}

It reads in characters from stdin and increments a counter, nc.

When I compile and run it in git bash, nc never gets printed after the program terminates.

CTRL+Z, and CTRL+C just stop the program.

How do I send EOF in windows git bash terminal?

Johannes Schindelin

unread,
Aug 13, 2016, 11:05:24 AM8/13/16
to Thane Michael, git-for-windows
Hi Michael,
Ctrl+D

Or you pipe the input into the program, like so:

echo 123 | ./a1.out

(this assumes that you compiled to a1.out, as was the standard in K&R
times).

Ciao,
Johannes
Reply all
Reply to author
Forward
0 new messages