I've heard there is a version of sprintf(), possibly a GNU/gcc extension which either allocates its own buffer which I must free() or perhaps works using the stack like alloca().
Either method is fine for me. Can anyone tell me what function I was thinking of?