c - Printing a wchar_t gives weird output -
running code snippet:
wchar_t *wstr = l"áßå®"; wprintf(l"%s",wstr);
gives output:
«
instead of
áßå®
i new wchar_t
. how expected output?
i believe, need change code
wprintf(l"%s",wstr);
to
wprintf(l"%ls",wstr);
ref: c11
standard, chapter §7.29.2.1, emphasis mine
l (ell)
specifies following d, i, o, u, x, or x conversion specifier applies long int or unsigned long int argument; following n conversion specifier applies pointer long int argument; following c conversion specifier applies wint_t argument; that followings
conversion specifier applies pointerwchar_t
argument; or has no effect on following a, a, e, e, f, f, g, or g conversion specifier.
Comments
Post a Comment