Prolog has an equivalent of the C library printf, which is format/2 or format/3.
But what is the equivalent of sprintf ?
You can use format/3
providing string(S)
or atom(A)
as the first argument:
?- format(string(String), 'Hello ~w', ['World!']).
String = "Hello World!".
?- format(atom(String), 'Hello ~w', ['World!']).
String = 'Hello World!'.