wchar_t question.

Started by
4 comments, last by SiCrane 12 years, 2 months ago
In my book called symfonia c++ author wrote:

wchar_t a;
a = L'b;


Does it mean that i must put (L) always before ('b') etc.?
I dont understand quite diffrent bettween L'b' and 'b'.
Advertisement
'b' is a regular char literal. Prefixing it with L makes it a wide character literal. The same deal with quotes. "b" is a regular char string. L"b" is the wide character string with equivalent contents.
when you write L you convert 16 bit your char

when you write L you convert 16 bit your char

No, it's not necessarily 16-bits. Most *nix systems use 32-bit wide characters.
So, i must use L always when i put value in variable with wchar_t type?
No, L is only used to prepend character literals and string literals to turn them into wide character literals and wide string literals. If you have a wchar_t variable you can assign it to another wchar_t variable without needing to use L on that assignment.

This topic is closed to new replies.

Advertisement