Quirrel4.41.0

string.printf

Defined in module "string"
from "string" import printf
printf(fmt: string, ...)

Formats fmt with the following arguments and writes the result to the same output as print, without building and returning a throwaway string.

Parameters

fmtstringthe format string
...anyone value per conversion in fmt repeats

Return value

null, always; the formatted text goes to the print output, not to the caller.

Errors

The same as format, since printf builds the string the same way before writing it.

Example

examples/string/printf.nut
from "string" import printf

// same formatting rules as format(), but writes the result instead of
// returning it, without building a throwaway string first
printf("%s = %d\n", "answer", 42)

// the call itself evaluates to null
println(printf("%d\n", 1) == null)
Output:
answer = 42
1
true

See also

formatFormats fmt with the following arguments, following the syntax of the C printf family, and returns the result as a new string.
stringmodule index