1. Module (chicken format)
    1. The printf family of procedures
      1. printf
      2. fprintf
      3. sprintf
    2. format

Module (chicken format)

This module provides procedures for formatting output to ports and strings.

The printf family of procedures

printf

fprintf

sprintf

[procedure] (fprintf PORT FORMATSTRING [ARG...])
[procedure] (printf FORMATSTRING [ARG...])
[procedure] (sprintf FORMATSTRING [ARG...])

Simple formatted output to a given port (fprintf), the value of (current-output-port) (printf), or a string (sprintf). The FORMATSTRING can contain any sequence of characters. There must be at least as many ARG arguments given as there are format directives that require an argument in FORMATSTRING. Extra ARG arguments are ignored. The character `~' prefixes special formatting directives:

~% write newline character
~N the same as ~%
~S write the next argument
~A display the next argument
~\n skip all whitespace in the format-string until the next non-whitespace character
~B write the next argument as a binary number
~O write the next argument as an octal number
~X write the next argument as a hexadecimal number
~C write the next argument as a character
~~ display `~'
~! flush all pending output
~? invoke formatted output routine recursively with the next two arguments as format-string and list of parameters

format

[procedure] (format [DESTINATION] FORMATSTRING [ARG...])

The parameters FORMATSTRING and ARG... are as for printf.

The optional DESTINATION, when supplied, performs:

#f
sprintf
#t
printf
output-port
fprintf
sprintf

Previous: Module (chicken foreign)

Next: Module (chicken gc)