Chicken » Module (chicken format)

## Module (chicken format)

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

### The printf family of procedures

#### printf

#### fprintf

#### sprintf

fprintf PORT FORMATSTRING #!optional ARG...procedure
printf FORMATSTRING #!optional ARG...procedure
sprintf FORMATSTRING #!optional ARG...procedure

  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

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

  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)