Re: sprintf basics (was: C99 IDE for windows)
On Wed, 06 Aug 2008 14:01:59 +0530, santosh wrote:
so, for both sprintf and snprintf, the character count must be N-1,
reserving the last character for null.
I downloaded it, 3.6 MB ,went straight to section 7.19.6.6 for sprintf.
Sadly after reading it and experimenting with both, I am no longer happier
at using snprintf as a replacement, in my specific case, as I already know
the maximum number of characters to be written.
--
my email is @ the above blog
check the "About Myself" page
On Wed, 06 Aug 2008 14:01:59 +0530, santosh wrote:
No. With snprintf N-1 characters will be written to a buffer of N
elements and then a null character will be added. With sprintf however
many characters that are generated by interpretation of the format
specifier and the subsequent arguments, if any, will be written and a
null character added at the end.
elements and then a null character will be added. With sprintf however
many characters that are generated by interpretation of the format
specifier and the subsequent arguments, if any, will be written and a
null character added at the end.
reserving the last character for null.
See the draft Standard for details. Search for n1256.pdf with Google.
Sadly after reading it and experimenting with both, I am no longer happier
at using snprintf as a replacement, in my specific case, as I already know
the maximum number of characters to be written.
--
my email is @ the above blog
check the "About Myself" page
Comment