Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ character constant notation

Tags:

c++

I'm seeing some character constant notation in C++ code that looks alien to me. Please educate me on this:

if (dc == L' '){

What does the L indicate?

Is it part of the standard?

Thanks,

lang2

like image 223
lang2 Avatar asked Dec 01 '22 22:12

lang2


1 Answers

L is a literal specifier. For characters, it means wchar_t, so the type of L'a' is wchar_t. For strings, it means "array of wchar_t", so L"hello" is a wchar_t[6]. (And for integers, it means "long", so 1L is a long int.)

like image 172
Kerrek SB Avatar answered Dec 19 '22 20:12

Kerrek SB