Here's a nice C puzzle this evening.
-
Here's a nice C puzzle this evening.
What type is a L'c' wide character constant?
Answer: wchar_t.
What type does the fprintf '%lc' format take?
Answer: wint_t.
So you need to cast your wide character when printing it with the conversion specifier which accepts wide characters.
Also, shout-out to gcc for msp430 where wchar_t is 32 bits (long int) and wint_t is 16 bits (unsigned int). I'm sure there's a story there.
-
Here's a nice C puzzle this evening.
What type is a L'c' wide character constant?
Answer: wchar_t.
What type does the fprintf '%lc' format take?
Answer: wint_t.
So you need to cast your wide character when printing it with the conversion specifier which accepts wide characters.
Also, shout-out to gcc for msp430 where wchar_t is 32 bits (long int) and wint_t is 16 bits (unsigned int). I'm sure there's a story there.
@keithp isn't wint_t supposed to be at least as wide as wchar_t since it must be able to store any wchar_t plus WEOF?