c include delay

Solutions on MaxInterview for c include delay by the best coders in the world

showing results for - "c include delay"
Karl
11 Apr 2016
1/** really not much to say...
2   just a way to program a delay
3   between commands in your code. **/
4
5//C library statement
6#include <time.h>
7
8//Driver program
9void dealy(int numOfSec)
10{
11	/* the delay itself runs with milli seconds
12	   so here we multiply the seconds by 1000.  */
13	int numOfMilliSec = 1000 * numOfSec;
14	
15	/* Making the time pass with nothing running
16	   until the time is up.                     */
17	time_t startTime = clock();
18	while(clock() < startTime + numOfMilliSec);
19}
20
21/*To use the delay just use the command:
22  delay(x);
23  you need to replace x with the number
24  of seconds that you want the delay to
25  be.                                    */
26  
27///The code itself without the details:
28
29#include <time.h>
30
31void delay(int numOfSec)
32{
33	int numOfMilliSec = 1000 * numOfSec;
34	time_t startTime = clock();
35	while(clock() < startTime + numOfMilliSec);
36}
Luis
26 May 2018
1// for micro programming use(havnt tested in other projects):
2#include <delay.h>