Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
/* Modified from the MSDN clock() fn description. */
/* Pauses for a specified number of milliseconds. */
void sleep( clock_t wait )
{
clock_t goal;
goal = wait + clock();
while( goal > clock() && !_kbhit())
;
}
/* Flush keyboard buffer */
void KbFlush()
{
while (_kbhit())
getch();
}
bool isClockOK()
{
clock_t t = clock();
return t != (clock_t)-1;
}
static int GetT(clock_t msec = 0)
{
int c = 0;
sleep(msec);
if (_kbhit())
{
c = _getche();
}
return c;
}
/* Console string input with timeout. Busy wait loop! */
char* tgets(char* line, int n, int timeoutms)
{
int c, k = 0;
if (!line || n <= 0)
return 0;
--n; /* reserve a room for zero terminator */
while (k < n)
{
c = GetT(timeoutms);
if (c)
{
if (c == '\n' || c == '\r') /* Enter pressed */
break;
line[k++] = c;
}
else /* Time out */
{
line[k] = '\0';
return 0;
}
}
line[k] = 0;
return line;
}
...
char line[80];
if (tgets(line,sizeof line, 1000*60*2)) /* 2 minuts */
{
/* Process input line with sscanf */
}
else /* Time out! */