swprintf


swprintf

Stores formatted output in a wide-character string buffer

 #include <wchar.h> int swprintf ( wchar_t * restrict dest , size_t n ,               const wchar_t * restrict format , ... ); 

The swprintf( ) function is similar to snprintf( ), except that its format string argument and its output are strings of wide characters.

Example

 const wchar_t *dollar_as_wstr( long amount) // Converts a number of cents into a wide string showing dollars and cents. // For example, converts (long)-123456 into the wide string L"-$1234.56" {   static wchar_t buffer[16], sign[2] = L"";   if ( amount < 0L)     amount = -amount, sign[0] = '-';   ldiv_t dollars_cents = ldiv( amount, 100);   swprintf( buffer, sizeof(buffer),             L"%ls$%ld.%2ld", sign, dollars_cents.quot, dollars_cents.rem );   return buffer; } 

See Also

wprintf( ) and fwprintf( ), declared in stdio.h and wchar.h; and vwprintf( ), vfwprintf( ), and vswprintf( ), declared in stdarg.h; printf( ), fprintf( ), sprintf( ), snprintf( ), declared in stdio.h; vprintf( ), vfprintf( ), vsprintf( ), vsnprintf( ), declared in stdarg.h; the wscanf( ) input functions. Argument conversion in the printf( ) family of functions is described in detail under printf( ) in this chapter.



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net