I have a ncurses assignment

How to use ese key in ncures library.

if(c == KEY_ESC)
{
endwin();

}

above code is not working.