Let`s say I need to read a character from the keyboard and then check if this character is valid (have some function) in the current menu part. So, if I am in firstMenu, search firstMenuKeys items, then if the character is found, call some function, otherwise throw this character. Maybe the Enum is not suitable for this purpose.
enum firstMenuKeys { UP = 72, DOWN = 80, LEFT = 75, RIGHT = 77, ENTER = 101, }; enum secondMenuKeys { UP = 72, DOWN = 80, ENTER = 101, }; int main() { char c; c = getch(); //check whether c is in firstMenuKeys }
https://stackoverflow.com/questions/65837596/check-if-character-is-in-enum-in-c January 22, 2021 at 08:11AM
没有评论:
发表评论