putchar - puts a single character out to the given
File
or to io::Output
putchar(
ch)
putchar(
file, ch)
file.putchar(
ch)
Puts a single character to the given file. If the
file is not provided, the character will be written to
io::Output
. The character ch is always
converted to Int
. In text-mode, it will write the
ch as a UTF-8 sequence. In binary-mode, it will write 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)
// The equivalent of Unix "cat" proc main() { var ch; do { ch = getchar(); if (ch != io::EOF) putchar(ch); } while (ch != io::EOF); }