somVprintf
Appearance
This function prints a formatted string in the manner of the C vprintf function.
Syntax
string fmt; va_list ap; long rc; rc = somVprintf(fmt, ap);
Parameters
- fmt(string)
- The format string to be output.
- ap (va_list)
- A va_list representing the values to be substituted into the format string.
Return Code
- rc (long)
- Returns the number of characters written.
Remarks
This 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.)
Example Code
#include <som.h>
main()
{
va_list args;
somVaBuf vb;
float f = 3.1415;
char c = 'a';
int one = 1;
char *msg = "This is a test";
somEnvironmentNew(); /* Init environment */
vb = (somVaBuf)somVaBuf_create(NULL, 0);
somVaBuf_add(vb, (char *)&one, tk_long);
somVaBuf_add(vb, (char *)&f, tk_float);
somVaBuf_add(vb, (char *)&c, tk_char);
somVaBuf_add(vb, (char *)&msg, tk_pointer);
somVaBuf_get_valist(vb, &args);
somVprintf("%d, %f, %c, %s\n", args);
}
Related
- Data Structures
- string (somcorba.h)
- va_list (stdarg.h)
- Functions