| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | getchar and EOF |
>> while((c=getchar()) != EOF) >> What character input from the keyboard represents the EOF >> character/key? AM>> Crtl-Z (I'm almost 99.99999999999% sure). This should be > This is correct... AM>> while((c=getchar()) != '\x27') > This is not. (Try it - getchar() should never return ctrl-Z - > it'll return EOF instead!) getch[e]() returns '\x27' I know that (at least under DOS and Windows). >#include >int getchar(void); > >Description > >Gets character from stdin. >getchar is a macro that returns the next character on the named input stream stdin. It is >defined to be getc(stdin). > >Note: Do not use this function for Win32s or Win32 GUI applications. > >Return Value > >On success, getchar returns the character read, after converting it to an int without sign >extension. >On end-of-file or error, it returns EOF. > Yeap. You are right. Except that this function does not wait for user to press the key - it only reads from the keyboard buffer making it kind of awkward for most applications. ---* Origin: The AstroMan (1:348/807.11) SEEN-BY: 396/1 632/0 371 633/260 267 270 371 634/397 635/506 728 639/252 SEEN-BY: 670/218 @PATH: 348/105 12/12 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™.