1-38 SOMobjects Base Toolkit: Programmer’s Reference Manual
somVprintf Function
Purpose
Prints a formatted string in the manner of the C vprintf function.
Syntax
long somVprintf (string fmt, va_list ap);
Description
The somVprintf function prints a formatted string using SOMOutCharRoutine, in the same
manner as the C vprintf function. The implementation of SOMOutCharRoutine determines
the destination of the output, while the C printf function is always directed to stdout. (The
default output destination for SOMOutCharRoutine is stdout also, but this can be modified
by the user.)
Parameters
fmt The format string to be output.
ap A va_list representing the values to be substituted into the format string.
Return Value
Returns the number of characters written.
C Example
#include <som.h>
main()
{
va_list args = (va_list) SOMCalloc(20);
va_list push = args;
float f = 3.1415
char c = ’a’;
va_arg(push, int) = 1;
va_arg(push, double) = f; /* note ANSI widening */
va_arg(push, int) = c; /* here, too */
va_arg(push, char*) = ”this is a test”;
somVprintf(”%d, %f, %c, %s\n”, args);
}
Related Information
Functions: somPrintf, somPrefixLevel, somLPrintf, SOMOutCharRoutine
Data Structures: string (somcorba.h), va_list (stdarg.h)
Komentáře k této Příručce