Difference between revisions of "c/io/vfwprintf"
D41D8CD98F (Talk | contribs) (→Parameters: pass `wcs=true` to template:cpp/io/c/printf format, so that the latter will know when it is dealing with wide character output functions) |
m (References; language links) |
||
Line 71: | Line 71: | ||
02/20/15 22:12:38.476575 UTC [debug]: Logging, 1, 2, 3 | 02/20/15 22:12:38.476575 UTC [debug]: Logging, 1, 2, 3 | ||
}} | }} | ||
+ | |||
+ | ===References=== | ||
+ | {{ref std c11}} | ||
+ | {{ref std | section=7.29.2.5 | title=The vfwprintf function | p=417-418}} | ||
+ | {{ref std | section=7.29.2.7 | title=The vswprintf function | p=419}} | ||
+ | {{ref std | section=7.29.2.9 | title=The vwprintf function | p=420}} | ||
+ | {{ref std | section=K.3.9.1.6 | title=The vfwprintf_s function | p=632}} | ||
+ | {{ref std | section=K.3.9.1.9 | title=The vswprintf_s function | p=634-635}} | ||
+ | {{ref std | section=K.3.9.1.11 | title=The vwprintf_s function | p=636}} | ||
+ | {{ref std c99}} | ||
+ | {{ref std | section=7.24.2.5 | title=The vfwprintf function | p=363}} | ||
+ | {{ref std | section=7.24.2.7 | title=The vswprintf function | p=364}} | ||
+ | {{ref std | section=7.24.2.9 | title=The vwprintf function | p=365}} | ||
+ | {{ref std end}} | ||
===See also=== | ===See also=== | ||
Line 79: | Line 93: | ||
{{dsc end}} | {{dsc end}} | ||
+ | [[ar:c/io/vfwprintf]] | ||
+ | [[cs:c/io/vfwprintf]] | ||
[[de:c/io/vfwprintf]] | [[de:c/io/vfwprintf]] | ||
[[es:c/io/vfwprintf]] | [[es:c/io/vfwprintf]] | ||
Line 84: | Line 100: | ||
[[it:c/io/vfwprintf]] | [[it:c/io/vfwprintf]] | ||
[[ja:c/io/vfwprintf]] | [[ja:c/io/vfwprintf]] | ||
+ | [[ko:c/io/vfwprintf]] | ||
+ | [[pl:c/io/vfwprintf]] | ||
[[pt:c/io/vfwprintf]] | [[pt:c/io/vfwprintf]] | ||
[[ru:c/io/vfwprintf]] | [[ru:c/io/vfwprintf]] | ||
+ | [[tr:c/io/vfwprintf]] | ||
[[zh:c/io/vfwprintf]] | [[zh:c/io/vfwprintf]] |
Revision as of 05:17, 4 April 2015
Defined in header <wchar.h>
|
||
int vwprintf( const wchar_t* format, va_list vlist ); |
(1) | (since C95) |
int vfwprintf( FILE* stream, const wchar_t* format, va_list vlist ); |
(2) | (since C95) |
int vswprintf( const wchar_t* buffer, size_t size, const wchar_t* format, va_list vlist ); |
(3) | (since C95) |
Loads the data from locations, defined by vlist
, converts them to wide string equivalents and writes the results to a variety of sinks.
stream
.buffer
. At most size-1 wide characters are written followed by null wide character.Contents |
Parameters
stream | - | output wide stream to write to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
buffer | - | pointer to a wide string to write to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
buf_size | - | maximum number of wide characters to write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
format | - | pointer to a null-terminated wide string specifying how to interpret the data.
The format string consists of ordinary wide characters (except
The following format specifiers are available:
The floating-point conversion functions convert infinity to Not-a-number is converted to The conversions Even though The correct conversion specifications for the fixed-width character types (int8_t, etc) are defined in the header The memory-writing conversion specifier %n is a common target of security exploits where format strings depend on user input and is not supported by the bounds-checked There is a sequence point after the action of each conversion specifier; this permits storing multiple %n results in the same variable or, as an edge case, printing a string modified by an earlier %n within the same call. If a conversion specification is invalid, the behavior is undefined.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
vlist | - | variable argument list containing the data to print |
Return value
size
.Example
#include <stdio.h> #include <time.h> #include <locale.h> void debug_wlog(const wchar_t *fmt, ...) { struct timespec ts; timespec_get(&ts, TIME_UTC); char time_buf[100]; size_t rc = strftime(time_buf, sizeof time_buf, "%D %T", gmtime(&ts.tv_sec)); snprintf(time_buf + rc, sizeof time_buf - rc, ".%06ld UTC", ts.tv_nsec / 1000); va_list args; va_start(args, fmt); wchar_t buf[1000]; int rc2 = vswprintf(buf, sizeof buf / sizeof *buf, fmt, args); va_end(args); if(rc2 > 0) wprintf(L"%s [debug]: %ls\n", time_buf, buf); else wprintf(L"%s [debug]: (string too long)\n", time_buf); } int main(void) { setlocale(LC_ALL, ""); debug_wlog(L"Logging, %d, %d, %d", 1, 2, 3); }
Possible output:
02/20/15 22:12:38.476575 UTC [debug]: Logging, 1, 2, 3
References
- C11 standard (ISO/IEC 9899:2011):
- 7.29.2.5 The vfwprintf function (p: 417-418)
- 7.29.2.7 The vswprintf function (p: 419)
- 7.29.2.9 The vwprintf function (p: 420)
- K.3.9.1.6 The vfwprintf_s function (p: 632)
- K.3.9.1.9 The vswprintf_s function (p: 634-635)
- K.3.9.1.11 The vwprintf_s function (p: 636)
- C99 standard (ISO/IEC 9899:1999):
- 7.24.2.5 The vfwprintf function (p: 363)
- 7.24.2.7 The vswprintf function (p: 364)
- 7.24.2.9 The vwprintf function (p: 365)
See also
(C99)(C11)(C11)(C11)(C11) |
prints formatted output to stdout, a file stream or a buffer using variable argument list (function) |
(C95)(C95)(C95)(C11)(C11)(C11)(C11) |
prints formatted wide character output to stdout, a file stream or a buffer (function) |
C++ documentation for vwprintf, vfwprintf, vswprintf
|