Here is my code:
#include <ncurses.h>
#include <string.h>
int main() {
char str[120];
char c;
while (1) {
printf("%s", ">");
scanf("%s", str);
if (!strcmp(str, "open")) {
initscr();
c=getch();
endwin();
printf("from curses window %c\n",c);
}
printf("%s\n", str);
}
return 0;
}
I have a while(1)
loop that always prints whatever it gets from screen.
If you input "open", it will open a curses window, and get a char
. After that it will exit the curses window (endwin()
), and should still be in the while(1)
loop.
But my problem is that after calling endwin()
it won't go back to the normal printf()/scanf()
loop.