TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Dennis Brown
from: Bob Stout
date: 1998-11-14 05:58:26
subject: getchar and EOF

On , Dennis Brown (1:133/1004.3{at}fidonet) wrote: 

 > A bit confused here... I was reading "Introduction to C",
(not sure what
 > edition), and in the beginning chapter, they give an example of getchar().

 > int c=0,nc=0;
 > while((c=getchar()) != EOF)
 > {putchar(c);
 > ++nc;
 > }
 > printf("Total number of characters is %d\n",nc);

 > What character input from the keyboard represents the EOF character/key?

Dennis...

  EOF is an internal flag which indicates that there was no character
available. In your example, it will read stdin until there's no longer 


--- QM v1.00
* Origin: MicroFirm : Down to the C in chips (1:106/2000.6)
SEEN-BY: 396/1 632/0 371 633/260 267 270 371 634/397 635/506 728 639/252
SEEN-BY: 670/218
@PATH: 30883/6 106/2000 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™.