Returns the decimal ASCII code representing the character read from the keyboard input buffer or from an open file
(read-char [file-desc])
Arguments
open) referring to an open file. If no file-desc is specified, read-char obtains input from the keyboard input buffer.
A file descriptor (obtained fromReturn Values
read-char function returns a single newline character (ASCII code 10) whenever it detects an end-of-line character or character sequence.
An integer representing the ASCII code for a character. TheExamples
read-char looks for data in the keyboard buffer:
The following example omits file-desc, soCommand: (read-char)
read-char waits for user input:
The keyboard buffer is empty, soABC
65
ABC; read-char returned the ASCII code representing the first character entered (A). The next three calls to read-char return the data remaining in the keyboard input buffer. This data translates to 66 (the ASCII code for the letter B), 67 (C), and 10 (newline), respectively:
The user enteredCommand: (read-char)
66
Command: (read-char)
67
Command: (read-char)
10
read-char waits for user input the next time it is called:
With the keyboard input buffer now empty,Command: (read-char)