Bug#43728: [v]snprintf return value ?
Package: glibc-doc, manpages-dev
Version: 2.1.1-12, 1.22-2
According to glibc-doc:
File: libc.info, Node: Formatted Output Functions, Next: Dynamic Output, Prev: Other Output Conversions, Up: Formatted Output
...
- Function: int snprintf (char *S, size_t SIZE, const char *TEMPLATE,
...)
...
The return value is the number of characters which would be
generated for the given input, excluding the trailing null. If
this value is greater or equal to SIZE, not all characters from
the result have been stored in S. You should try again with a
bigger output string. Here is an example of doing this:
According to snprintf(3):
NAME
snprintf, vsnprintf - formatted output conversion
...
RETURN VALUE
If the output was truncated, the return value is -1, oth
erwise it is the number of characters stored, not includ
ing the terminating null.
I submit that the behaviour documented in the info file is more
useful.
Ian.
Reply to: