Ooo. The plot thickens.
-
Ooo. The plot thickens.
What does printf("%c", '\0') do?
Answer: output a character of value 0.
What should printf("%lc", (wint_t)L'\0') do?
Answer: output nothing.
That's because %lc is *defined* to be equivalent to %ls with a two-element wchar_t array, the first holding the wint_t parameter (cast to a wchar_t) and the second a null wide character. If I'm right, then glibc has a bug here.
-
undefined oblomov@sociale.network shared this topic
-
Ooo. The plot thickens.
What does printf("%c", '\0') do?
Answer: output a character of value 0.
What should printf("%lc", (wint_t)L'\0') do?
Answer: output nothing.
That's because %lc is *defined* to be equivalent to %ls with a two-element wchar_t array, the first holding the wint_t parameter (cast to a wchar_t) and the second a null wide character. If I'm right, then glibc has a bug here.
@keithp apparently this isn't a glibc issue but a decision shared with at least some of the BSDs?
e.g. OpenBSD also prints a single wide character.