When I'm using PDcurses and I try to have a while loop exit when the enter key is pressed with while(key != KEY_ENTER)
, the while loop never exits. However, when I try to have the same loop exit with while((char)key != '\n')
, it exits successfully whenever I pressed enter. Why does '\n'
work and not KEY_ENTER
?
btw, key
is an int
and I hope this is the relevant few lines of the code:
int key;
while((char)key != '\n') {
key = getch();
...
}