Answer the question
In order to leave comments, you need to log in
How to separate pressing arrows and pressing Russian letters?
Hello. The getch() command returns the ASCII number of the pressed key. Russian letters are numbered in the ranges 127-176 and 223-242, inclusive. The arrow code consists of two numbers, where the first is always 224, which also stands for the letter 'p' and as a result the following code will not work, because if the letter 'p' was entered, the program will wait for the next letter to be entered.
int ch = getch();
if (ch == 224) {
int arrow = getch();
switch (arrow) {
... // обработка стрелок
}
}
Answer the question
In order to leave comments, you need to log in
The arrows do indeed generate two codes, but the first code is still 0, not 224.
You don't need getch, don't use it.
https://docs.microsoft.com/en-us/cpp/c-runtime-lib...
If you still want to use it, then you will have to make a wrapper yourself to handle double-byte characters.
But everything is already invented, try _getwchar
https://docs.microsoft.com/en-us/cpp/c-runtime-lib...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question