TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Darin Mcbride
from: Dennis Brown
date: 1998-11-09 07:47:58
subject: getchar and EOF

Hello Darin!
In a message to Dennis Brown  Darin Mcbride wrote:
 DB> beginning chapter, they give an example of getchar().
 DB> int c=0,nc=0;
 DB> while((c=getchar()) != EOF)
 DB> {putchar(c);
 DB> ++nc;
 DB> }
 DB> printf("Total number of characters is %d\n",nc);
 DB> What character input from the keyboard represents the EOF character/key?
DM> That's platform-specific.  Worse, it can be set up by the user on some
DM> platforms.  In general, and by default (IIRC):
DM> DOS, Windows (Win32 console only), OS/2:  Ctrl-Z
DM> Unix: Ctrl-D
DM> On unix, you can usually set your system to use a different EOF character.
DM> However, I'm guessing DOS here... and I don't know of a way to change the
DM> EOF character on DOS.
DM> Also, this only applies in "ascii" or "text"
mode, not "binary" mode which
DM> doesn't have an EOF character.  Not to worry, however, since stdin, if not
DM> redirected from a file, is opened in text mode for you.
DM> Hope this helps,

Thanks, yes it does help.  I knew the Ctrl-Z was EOF in a text file, but
wasn't sure about the keyboard!
Thanks,
Dennis

 * WCE 2.1G1/2402 * ..."Visually Challenged as a bat!!"

--- WILDMAIL!/WC v4.00 
* Origin: DB-Tech (1:133/1004.3)
SEEN-BY: 396/1 632/0 371 633/260 267 270 371 634/397 635/506 728 639/252
SEEN-BY: 670/218
@PATH: 133/1004 1023 2 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.