| getc |
(Stream stream) |
yoix.stdio |
| |
Returns an integer that represents the next character read from
stream,
or
-1
at the end-of-stream or when an error occurs.
Note that
getc
is identical to
fgetc
and is included only as a convenience for those accustomed to using
one or the other when writing C programs.
| |
| Example: |
The simple program,
import yoix.stdio.*;
int ch;
while ((ch = getc(stdin)) != -1)
putc(ch, stdout);
copies standard input to standard output one character at a time,
so it is 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: |
fgetc,
fputc,
getchar,
putc,
putchar,
ungetc
|
|
Yoix is a registered trademark of AT&T Inc.
|