| getchar |
() |
yoix.stdio |
| |
Returns an integer that represents the next character read from
the standard input stream
stdin,
or
-1
at the end-of-stream or when an error occurs.
| |
| Example: |
The program,
import yoix.stdio.*;
int ch;
while ((ch = getchar()) != -1)
putchar(ch);
copies standard input to standard output one character at a time,
so it is very slow.
There is another way to do exactly the same thing that is a bit faster
because it avoids the overhead involved in calling built-ins.
Run
int ch;
while ((ch = stdin.nextchar) != -1)
stdout.nextchar = ch;
and you will copy standard input to standard output one character at a time.
You will find more details in our discussion of the
Stream
type.
| | |
| Return: |
int
| | |
| See Also: |
getc,
putc,
putchar,
ungetc
|
|
Yoix is a registered trademark of AT&T Inc.
|