ungetc - returns a single character to the input buffer of the
given File or to io::Output
ungetc(ch)
ungetc(file, ch)
file.ungetc(ch)
Returns a single character to the input buffer of the given
file. If the file is not provided, the character will
be returned to io::Output. The character
ch is always converted to Int. In
text-mode, it will buffer the ch as a UTF-8 sequence. In
binary-mode, it will buffer the ch as an unsigned byte.
None
ArgCheck for an incorrect number of arguments
TypeCheck for a non-File
file or non-numeric ch
AccessCheck for an attempt to access a closed
file
IoCheck for other
miscellaneous I/O errors (see ferror)
// Use getchar/ungetc to peek ahead for EOF
proc main()
{
var ch;
ch = getchar();
while (ch != io::EOF) {
ungetc(ch);
var str = readstr();
"", str, '\n';
ch = getchar();
}
}