SomVprintf: Difference between revisions
Appearance
Created page with "This function prints a formatted string in the manner of the C vprintf function. ==Syntax== <PRE> string fmt; va_list ap; long rc; rc = somVprintf(fmt, ap); </P..." |
mNo edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:somVprintf}} | |||
This function prints a formatted string in the manner of the C vprintf function. | This function prints a formatted string in the manner of the C vprintf function. | ||
==Syntax== | ==Syntax== | ||
string fmt; | |||
string fmt; | va_list ap; | ||
va_list ap; | long rc; | ||
long rc; | |||
rc = somVprintf(fmt, ap); | |||
rc = somVprintf(fmt, ap); | |||
==Parameters== | ==Parameters== | ||
; fmt(string) : The format string to be output. | ;fmt(string): The format string to be output. | ||
;ap (va_list): A va_list representing the values to be substituted into the format string. | |||
; ap (va_list) : A va_list representing the values to be substituted into the format string. | |||
==Return Code== | ==Return Code== | ||
; rc (long): Returns the number of characters written. | ;rc (long): Returns the number of characters written. | ||
==Remarks== | ==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.) | 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== | ==Example Code== | ||
Line 46: | Line 44: | ||
==Related== | ==Related== | ||
;Data Structures | |||
* string (somcorba.h) | * string (somcorba.h) | ||
* va_list (stdarg.h) | * va_list (stdarg.h) | ||
;Functions | |||
* [[somPrintf]] | * [[somPrintf]] | ||
* [[somPrefixLevel]] | * [[somPrefixLevel]] | ||
* [[somLPrintf]] | * [[somLPrintf]] | ||
* [[SOMOutCharRoutine]] | * [[SOMOutCharRoutine]] | ||
[[Category:SOM | [[Category:SOM function]] |
Latest revision as of 02:26, 6 May 2020
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