2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
5 ANSI C function snprintf().
8 /*****************************************************************************
22 Formats a list of arguments and writes them into the string str.
25 str - The formatted string is written into this variable. You
26 must make sure that it is large enough to contain the
28 n - At most n characters are written into the string. This
30 format - Format string as described above
31 ... - Arguments for the format string
34 The number of characters written into the string. The 0 byte at the
35 end is not included. If this is greater than or equal to n then
36 there was not enough room to write all characters. In this case the
37 output string is not null-terminated, and the return value is the
38 number of characters which would have been written if enough space had
48 fprintf(), vprintf(), vfprintf(), snprintf(), vsprintf(),
53 ******************************************************************************/
58 va_start (args
, format
);
60 retval
= vsnprintf (str
, n
, format
, args
);
70 int main (int argc
, char ** argv
)
75 printf ("snprintf test\n");
77 rc
= snprintf (buffer
, sizeof (buffer
), "%10d", 5);
79 if (rc
< sizeof (buffer
))
80 printf ("rc=%d, buffer=\"%s\"\n", rc
, buffer
);
82 printf ("rc=%d\n", rc
);
84 rc
= snprintf (buffer
, sizeof (buffer
), "%11d", 5);
86 if (rc
< sizeof (buffer
))
87 printf ("rc=%d, buffer=\"%s\"\n", rc
, buffer
);
89 printf ("rc=%d\n", rc
);