Re: How To Implement Timer in C
- From: "yunyuaner@xxxxxxxxx" <yunyuaner@xxxxxxxxx>
- Date: 28 Feb 2007 01:33:27 -0800
On 2月28日, 下午1时15分, "UG" <unmeshgh...@xxxxxxxxx> wrote:
I just wanted to know whether any timer facility exists in C, as it is
not mentioned in K&R 2, or in the ISO Draft. By timer function i mean
that when we use standard input function like scanf() or getch() or
any other function, the interface stops to take input from user but
what if user doesn't give input for hours, the program will still be
waiting. Is there any way to circumvent the scanf() (or any other
input function for that matter) so that it takes some default input or
no input and just proceeds to the next line of the execution assuming
input from user as nothing and acts accordingly.
The above description is clear.
Many platforms provide timer, such as win32, in which you can use func
settimer
Anyway, there is a poor implementation of timer in linux
void sig_alrm(int signo)
{
return;
}
int main()
{
signal(SIGARLM, sig_alrm);
alarm(1);
scanf(...);
/* time up, your can capture the signal by checking errno */
return 0;
}
.
- Follow-Ups:
- Re: How To Implement Timer in C
- From: mark_bluemel
- Re: How To Implement Timer in C
- References:
- How To Implement Timer in C
- From: UG
- How To Implement Timer in C
- Prev by Date: Re: allocating mem in a function and assigning a ptr to the first byte of that mem array...
- Next by Date: Polyspace Problem
- Previous by thread: Re: How To Implement Timer in C
- Next by thread: Re: How To Implement Timer in C
- Index(es):
Relevant Pages
|