I dusted off the standard and I think it settles it:
Quote:
The fprintf function returns the number of characters transmitted, or a negative value if an output error occured.
|
Quote:
The sprintf function is equivalent to fprintf, except that the argument s specifies an array into which the generated output is to be written, rather than to a stream. A null character is written at the end of the characters written; it is not counted as part of the returned sum.
|
Quote:
The sprintf function returns the number of characters written in the array, not counting the terminating null character.
|
"Transmitted" must mean the amount of characters that the program attempts to write to stdout, regardless if stdout successfully outputs all characters, as opposed to
"written", which is used to describe sprintf.
(I should have checked this before asking but
cppreference.com says "returns number of characters written" for both.)
Obviously not a good general solution for sprintf but in my case I have to write the same thing to stdout and a buffer, so this works perfectly for me. I think.