#include #include #include #include #define MAX_LEN 200 void sigint_handler( int sig ) { printf( "Got an Interrupt!\n" ); } int main( void ) { char s[MAX_LEN]; if ( signal( SIGINT, sigint_handler ) == SIG_ERR ) { perror( "signal" ); exit( 1 ); } printf( "Enter a string:\n" ); if ( fgets( s, MAX_LEN, stdin ) == NULL ) perror( "fgets" ); else printf( "You entered: %s", s ); return 0; }