I want to have an Array of the Greek alphabet and this is what I do:
wchar_t pcletters[30] = {'α' , 'ά' , 'β' , 'γ' , 'δ' , 'ε' , 'ζ' , 'η', 'θ' , 'ι' , 'κ' , 'λ' , 'μ' , 'ν','ξ' , 'ο' , 'π' , 'ρ' , 'σ' , 'τ' , 'υ' , 'φ' , 'χ' , 'ψ' , 'ω', 'έ' , 'ή' , 'ί' , 'ό' , 'ύ' , 'ώ'} ;
I also include <locale.h>
and have a line setlocale(LC_CTYPE, "") .
However I get the warning warning: multi-character character constant [-Wmultichar]. Moreover when I get to check if one of this letters is in a user input by doing :
if (userword[i] == pcletters[j]) {//do stuff}
it does not seem to work.
-Why do I get this warning ?
-Is there a way to change pcletters in a way to be able to compare
the userword[i] == pcletters[j]
Note: userword
is defined like this: wchar_t userword[40]
.
Use wide character literals:
wchar_t pcletters[30] = {L'α' , ...
^
Note that this will only work on platforms where the letters you are writing are a single wide character; this should work on Windows, where wchar_t
is UCS-2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With