Use fcntl to change stdin to not block. Use the O_NONBLOCK flag.
Then use the 'select' statement to wait for a single character to be read from stdin. There is an example on the select man page. What it does not cover is changing stdin not to block. The following lines will cause stdin not to block.
Code:
int flags = fcntl( STDIN_FILENO, F_GETFL, 0 );
if ( fcntl( STDIN_FILENO, F_SETFL, flags | O_NONBLOCK ))
{
perror("fcntl error");
return -1;
}