#include <stdio.h>
#include <stdlib.h>
#include <ncurses.h>
#include <unistd.h> // For sleep function
int main() {
initscr(); // Initialize ncurses
printf("Press 'q' to exit...\n");
sleep(2);
clear();
refresh();
cbreak(); // Enable 'cbreak' mode, which doesn't wait for Enter key
noecho(); // Disable echoing of typed characters
nodelay(stdscr, TRUE); // Set getch() to be non-blocking
for (;;) {
int ch = getch(); // Read a single character without blocking
if (ch == 'q') {
printf("Exiting...\n");
sleep(2);
break;
}
printf("Message every 1 second...\n");
refresh(); // Refresh the ncurses screen
sleep(1); // Wait for 1 second
}
endwin(); // End ncurses
return 0;
}