
sprintf(-String, +Format, ?ArgList)

   The arguments in the argument list ArgList are interpreted according to the
Format string and the formatted result is unified with String.

Arguments
   String              Variable or String.
   Format              String or Atom.
   ArgList             List or any Term.

Type
   Term I/O

Description
    This predicate works exactly like printf/2,3 except that the formatted
    result is delivered in the form of a string.  See printf/3 for details.

    Note that for simple cases it is usually more efficient to use
    primitives like concat_string/2, join_string/3 or number_string/2.



Modes and Determinism
   sprintf(-, +, ?) is det

Modules
   This predicate is sensitive to its module context (tool predicate, see @/2).

Exceptions
     5 --- String is instantiated to something other than a string.
     5 --- Format is not an atom or a string.
     5 --- ArgList contains argument whose type does not correspond to the control sequence.
     7 --- Format is not correct, it contains too many asterisks or a control character is missing or there is a redundant character before the control character.
     8 --- ArgList has not enough or too many arguments.

Examples
   
Success:
?- sprintf(String, "abc %s ghi %+*.*E...", ["def", 2, 3, 12.34]).
String = "abc def ghi +1.234E+01..."
yes.

?- sprintf(String, "abc %12c %*n", [77, 3]).
String = "abc MMMMMMMMMMMM \n\n\n"
yes.

?- sprintf("x9", "x%d", [3]).
no.


See Also
   concat_string / 2, join_string / 3, number_string / 2, printf / 2, printf / 3
