Write formatted output to a string.
Compatibility:This function is compatible with the following targets:
|
|
#include <stdio.h>
int vsprintf(char *s,  
const char *format, va_list arg);
Parameters for this facility are:
For specifications concerning the output control string and conversion specifiers please see: "Output Control String and Conversion Specifiers."
Return: See Also:"Wide Character and Byte Character Stream Orientation"
Example of vsprintf() usage.:#include <stdio.h>
#include <stdarg.h>
int spr(char *, char *, ...);
int main(void)
{
int a = 56;
double x = 1.003;
static char name[] = "Metrowerks";
char s[50];
// format and send a variable number of arguments
// to character array s
spr(s, "%10s\n %f\n %-10d\n", name, x, a);
puts(s);
return 0;
}
// spr() formats and sends a variable number of
// arguments to a character array using the sprintf()
// function
int spr(char *s, char *format, ...)
{
va_list args;
int retval;
va_start(args, format); // prepare the arguments
retval = vsprintf(s, format, args);
va_end(args); // clean the stack
return retval;
}
Output:
Metrowerks
1.003000
56
[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.
Last updated: August 16, 2000