How to use wprintf() to print formatted data and C wide string to stdout in C

1 Answer

0 votes
#include <stdio.h>
 
 #define LEN 4
 
int main(void)
{
    wprintf(L"Characters: %lc %lc \n", L'z', 68);
    wprintf(L"Decimals: %d %ld\n", 3299, 990000L);
    wprintf(L"With leading blanks: %10d \n", 3299);
    wprintf(L"With leading zeros: %010d \n", 3299);
    wprintf(L"%%d %%x %%o %%#x %%#o : %d %x %o %#x %#o \n", 100, 100, 100, 100, 100);
    wprintf(L"floats: %4.3f %+.0e %E \n", 3.14159, 3.14159, 3.14159);
    wprintf(L"Width: %*d \n", 7, 100);
    wprintf(L"%ls \n", L"wide string");
    
    return 0;
}

 
/*
run:

Characters: z D
Decimals: 3299 990000
With leading blanks:       3299
With leading zeros: 0000003299
%d %x %o %#x %#o : 100 64 144 0x64 0144
floats: 3.142 +3e+000 3.141590E+000
Width:     100
wide string

*/

 



answered Aug 23, 2016 by avibootz

Related questions

...