char arr [] = {'a', 'b', 'c', 'g'} when I write such an array it gives an error "error: excess elements in char array initializer" what should I do to fix it? I did not write a console application in Qt (if necessary)
2 answers
Your source code has some kind of encoding, Cyrillic characters are written into the code in this encoding. Writing char arr [] = {'a', 'b', 'c', 'd'} means that you type the code in a single-byte encoding, and initialize the byte array with the codes of the Cyrillic letters in this particular encoding, while IDEs use unicode by default (for example, utf-8), hence the compilation error. If you really need an array of characters in unicode, then on Qt you can initialize it like this: QChar arr[] = {u'а', u'б', u'в', u'г'}
|
The char type does not support unicode. Therefore, use the wchar_t type.
|
std::stringor something like that. - HolyBlackCatchar, in Qt there are enough tools to work with Unicode. - ixSciutf-8, if the Cyrillic alphabet is in the code itself - gil9red