Page t022, go to NEXT,
PREVIOUS, INDEX
while Example
Example
#include <stdio.h>
int main()
{
char c;
while ( c = getc (stdin), c != EOF )
{ printf (" '%c' = %d\n", c, c);
}
return (0);
}
- reads characters from terminal until end-of-file
- <control>-d is end-of-file for UNIX
- separate expressions with commas in while clause
- value of last expression is used
C Course, 21-jan-1997,
Peter Klok,
pfk@hef.kun.nl