The functions snprintf() and vsnprintf() do not write more than size bytes (including the ter‐
minating null byte ('\0')). If the output was truncated due to this limit then the return
value is the number of characters (excluding the terminating null byte) which would have been
written to the final string if enough space had been available. Thus, a return value of size
or more means that the output was truncated. (See also below under NOTES.)
int snprintf(char *str, size_t size, const char *format, ...)
snprintf返回的是期待写入的字符串长度,
1 如果输出没有被阶段,返回size
2 如果输出被阶段,返回源输出字符串长度