Interesting, I thought I had invented this function myself (even giving it this name), but apparently it dates back to plan9 even (as seprint, rather than seprintf -- https://9fans.github.io/plan9port/man/man3/print.html).
Be careful of the handling of the negative snprintf() return case. At least historically, some snprintf implementations returned negative numbers in the case the output was truncated! This appears to not be permitted by C99 but I swear I saw it in a Windows
1 comment
[ 4.3 ms ] story [ 27.0 ms ] threadBe careful of the handling of the negative snprintf() return case. At least historically, some snprintf implementations returned negative numbers in the case the output was truncated! This appears to not be permitted by C99 but I swear I saw it in a Windows
Oh my, windows _snprintf also _doesn't NUL-terminate in this situation!_ -- use C99 compatible snprintf. Ugh! https://docs.microsoft.com/en-us/cpp/c-runtime-library/refer...