Otto Moerbeek wrote:
On Thu, 5 Jan 2006, veins wrote:
I'm having trouble making snprintf return -1. I've tried stuff like:
len = snprintf(str, 0, "%.-Z\n", 9);
printf("%d", len);
but that just prints `2'. Does snprintf ever return -1?
-Ray-
you might want to take a look at how vfprintf() is implemented in
/usr/src/lib/libc/stdio/
But that's just the implemenation. Which can change. The API defines
snprintf can return -1, so you should check for it.
On systems that support wide chars, snprintf can return -1 if an
encoding problem has occurred, for example.
-Otto
I know and agree, I was just replying to his "does it ever return -1" :-)