Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!thunder.mcrcim.mcgill.edu!quiche!storm From: storm@cs.mcgill.ca (Marc WANDSCHNEIDER) Newsgroups: comp.lang.c Subject: getchar() Summary: confusion using the getchar() command Message-ID: <1991Mar5.063644.8459@cs.mcgill.ca> Date: 5 Mar 91 06:36:44 GMT Sender: storm@cs.mcgill.ca (Marc WANDSCHNEIDER) Organization: SOCS, McGill University, Montreal, Canada Lines: 47 The following file: #include "stdio.h" main() { int c; c = getchar(); while (c != 65) { /* 65 is capital A on the PC*/ putchar(c); c = getchar(); } } Echos every character that you put on the screen. However, it does not stop (even after a Capital A) until you hit return. I changed the program to this: #include .... main() { long nc; nc = 0; while(getchar() !=65) ++nc; printf("%ld\n", nc); } This program STILL echos the characters I type in (even without the putchar()), and will only abort after I've hit the RETURN AFTER a "A". Can somebody offer some insight into what the hell is going on...? Also, is there and EOF character on the PC. The origional program for both the above cases was !=EOF, but I changed it to !=65.... Any help would be great. Thanks. ./*- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storm@cs.mcgill.ca McGill University It's 11pm, do YOU Marc Wandschneider Montreal, CANADA know what time it is? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~