COHERENT manpages

This page displays the COHERENT manpage for vsprintf() [Print formatted text into string].

List of available manpages
Index


vsprintf() -- STDIO Function (libc)

Print formatted text into string
#include <stdarg.h>
#include <stdio.h>
int
vsprintf(string, format, arguments)
char *string, *format; va_list arguments;

vsprintf() constructs a formatted string  in the area pointed to by string.
It translates integers,  floating-point numbers, and strings into a variety
of text  formats.  vsprintf()  can handle a  variable list of  arguments of
various types.   It is roughly equivalent to  the `%r' conversion specifier
to sprintf().

format points  to a string that can contain  text, character constants, and
one  or   more  conversion  specifications.    A  conversion  specification
describes  how to  convert a  particular data type  into a  particular text
format.  Each conversion  specification is introduced with the percent sign
`%'.  (To print a literal percent  sign, use the escape sequence `%%'.) See
printf() for  further discussion of the conversion  specification and for a
table of the type specifiers that can be used with vsprintf().

After format comes arguments. This is  of type va_list, which is defined in
the header  file stdarg.h. It has been initialized  by the macro va_start()
and points  to the base  of the list  of arguments used  by vsprintf(). For
more information, see va_arg().

arguments should  access one argument for  each conversion specification in
format  of  the  type appropriate  to  the  conversion specification.   For
example, if  format contains conversion specifications for  an int, a long,
and a  string, then arguments access  three arguments, being, respectively,
an int, a long, and a  char *. If there are fewer arguments than conversion
specifications,  then  vsprintf()'s  behavior  is undefined  (and  probably
unwelcome).  If there are more, vsprintf() evaluates and then ignores every
argument without a  corresponding conversion specification.  If an argument
is not of  the same type as its corresponding  type specification, then the
behavior of vsprintf() is  undefined; thus, accessing an int where vsprintf
expects a char * may generate unwelcome results.

If it writes the  formatted string correctly, vsprintf() returns the number
of characters written; otherwise, it returns a negative number.

See Also

fprintf(),
libc,
printf(),
sprintf(),
vprintf(),
vsprintf()
ANSI Standard, §7.9.6.9

Notes

vsprintf() can construct a string up to at least 509 characters long.