vsprintf
raw OCR
Writes formatted output to a string.
Defined in header <stdarg.h>
Syntax
#include <stdarg.h>
int vsprintf(char *bujfer, const char *format,vajist arglist);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ |
Remarks
Available on UNIX system V. The v...printf functions are known as alternate entry points for the ...printf functions. They behave exactly like their ...printf counterparts, but they accept a pointer to a list of arguments instead of an argument list.
See printf for details
vsprintf accepts a pointer to a series of arguments, applies to each
on format specifiers.
| a format | contained in the format | to |
| specifier | string pointed by |
format, and outputs the formatted data to a string. There must be the same number of format specifiers as arguments.
Return value
vsprintf returns the number of bytes output. In the event of error, vsprintf returns EOF.
See also
Example
#include <stdio.h>
#include <conio.h>
char buffer[80];
■ int vspf(char *fmt, ...)
{
va_list argptr;
int cnt;
va_start (argptr, fmt) ;
cnt = vsprintf(buffer, fmt, argptr);
va_end(argptr) ;
return (cnt);
}
int main (void)
{
int inumber =30;
float fnumber = 90.0;
char string[4] = "abc";
vspf("%d-%f %s", inumber, fnumber, string);
printf ("%s\n", buffer);
return 0;
}
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/stdarg.h/vsprintf/
· short form /3.1/vsprintf/