Printing wchar_t gives strange output
1 answer
I believe you need to change your code
wprintf(L"%s",wstr);
to
wprintf(L"%ls",wstr);
Ref: from the standard C11
, chapter §7.29.2.1, emphasis mine
l (ell)
Indicates that the next conversion specifier d, i, o, u, x, or X is applied to a long int or unsigned long int argument; that the next conversion pointer n is applied to a pointer to a long int argument; that the following conversion specifier c applies to the wint_t argument; that the next conversion pointers
is applied to the argument pointerwchar_t
; or does not affect the following conversions a, A, e, E, f, F, g, or G specifier.
+4
source to share