Forum Discussion
Altera_Forum
Honored Contributor
21 years agobreak loop with 'q'
Hello, this may be a very beginner question, but I cannot get ahead. I have a loop wich should be performed until the user presses 'q'. I tried with getchar() but it seems that getcha...
Altera_Forum
Honored Contributor
21 years agoThank you very much, works fine now.
My code:int32 KeyPressed( void )
{
int32 key = -1;
int32 flags;
/* save flags */
flags = fcntl( fileno(stdin), F_GETFL );
/* set non blocking */
if( ! fcntl( fileno(stdin), F_SETFL, flags | O_NONBLOCK ) );
{
key = getchar();
}
/* restore flags */
fcntl( fileno(stdin), F_SETFL, flags );
return( key );
}