NAME

getchar - reads a single character from the given File or io::Input

SYNOPSIS

getchar()
getchar(file)
file.getchar()

DESCRIPTION

Reads a single character from the given file. If the file is not provided, the character will be read from io::Input.

RETURN VALUE

The getchar() intrinsic procedure / method always returns an Int. In text-mode, it returns the next UTF-8 character code present in file. In binary-mode, it returns the next unsigned byte present in file. It will return io::EOF at the end-of-file.

ERRORS

ArgCheck for an incorrect number of arguments
TypeCheck for a non-File file
AccessCheck for an attempt to access a closed file
UTF8Check for reading a bad UTF-8 byte from a text-mode file
IoCheck for other miscellanous I/O errors (see ferror)

EXAMPLE

    // The equivalent of Unix "cat"
    proc main()
    {
        var ch;

        do {
            ch = getchar();
            if (ch != io::EOF) putchar(ch);
        } while (ch != io::EOF);
    }

SEE ALSO

new File
ferror
putchar