This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: snprintf() wrong return value for %c with \0 char


Mike Frysinger ha scritto:
On Wednesday 24 January 2007 05:56, Francesco Montorsi wrote:
Return value of snprintf(): 13

correct


Now, I'm not sure if the return value of snprintf() is supposed to be 6
or 13 in this case. I'd say the return value of snprintf() should always
be the same of that returned by strlen()....

incorrect ...


you're confusing the points at which the string is evaluated as a string ... snprintf is writing the given format string based upon the arguments ...

embedded null characters in the format string matter, arguments given via output specifiers do not matter
ok; thus in conclusion the current behaviour of snprintf() is the correct one...

Thanks!
Francesco


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]