build sprintf-like functions