Consider the following code;
Code:
#include <curses.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
int number = 1;
void quitter(void);
void quitter (void)
{
clear();
mvprintw(2,10, "Quitting...");
refresh();
sleep(4);
endwin();
exit(1);
}
int main ( void )
{
initscr();
mvaddstr(1,1,"Enter a number: ");
refresh();
while(1)
{
mvprintw (5,5, "%d", number);
move(1, 16);
refresh();
number = number + 1 ;
sleep(1);
signal (SIGINT, quitter);
//scanw ("%d", number); // NO GOOD - FREEZES LOOP
}
}
It almost seems that you need 2 programs running independently in parallel, but somehow connected.
Any input statement that allows the program to recognize the fact that the user has entered a number stops the program. Its a catch 22 that I cannot overcome.
