| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | getchar and EOF |
BB> Darin, > Also, this only applies in "ascii" or "text" mode, not > "binary" mode which doesn't have an EOF character. > Not to worry, however, since stdin, if not redirected > from a file, is opened in text mode for you. BB> That is not entirely, Darin. EOF is a constant BB> defined in stdio.h. What keystrokes are translated by BB> the implementation into the EOF constant in the input BB> stream depends on the implementation. No, it *is* entirely true. How it is translated is completely up to the system, just like NULL - EOF == -1 and NULL == (void*)0, but bit patterns depend on platform. However, that wasn't the question. Using the following code, how do you get it to terminate? while ((c = getchar()) != EOF) putchar(c); Answer? Use the "EOF character" on your platform: Ctrl-D on unix (or whatever you set it to), or Ctrl-Z on non-unix Intel. ---* Origin: Tanktalus' Tower BBS (1:250/102) SEEN-BY: 396/1 632/0 371 633/260 267 270 371 634/397 635/506 728 639/252 SEEN-BY: 670/218 @PATH: 250/102 201 99 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™.