feat: add fputc wrapper to IO (#1417)

* feat: add fputc wrapper to IO

fputc is a low-level function that writes a single C character to a
file. We can use this as a basis for more elegant APIs.

The signature matches that of the C standard library function for
compatibility, which takes an Int instead of a char. However, the
documentation notes that the int argument is converted to an unsigned
char.

* doc: fix typos for fgetc and fputc docs
This commit is contained in:
Scott Olsen 2022-04-19 09:29:26 -05:00 committed by GitHub
parent 5d530b7491
commit 9d9f982ce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,8 +16,10 @@ module are wrappers around the C standard library.")
(register stderr (Ptr FILE) "stderr")
(doc get-char "gets a character from stdin (thin wrapper for getchar() from C standard library).")
(register get-char (Fn [] Int) "getchar")
(doc fgetc "gets a character from file (thin wrapper for the from C standard library).")
(doc fgetc "gets a character from file (thin wrapper for fgetc from the C standard library).")
(register fgetc (Fn [(Ptr FILE)] Int) "fgetc")
(doc fputc "writes a character to a file (thin wrapper for fputc from the C standard library).")
(register fputc (Fn [Int (Ptr FILE)] Int) "fputc")
(doc EOF "the End-Of-File character as a literal (thin wrapper for the C standard library)")
(register EOF Int "EOF")
(private fopen-)