Answers for "C delay"

C
1

C delay

/** really not much to say...
   just a way to program a delay
   between commands in your code. **/

//C library statement
#include <time.h>

//Driver program
void dealy(int numOfSec)
{
	/* the delay itself runs with milli seconds
	   so here we multiply the seconds by 1000.  */
	int numOfMilliSec = 1000 * numOfSec;
	
	/* Making the time pass with nothing running
	   until the time is up.                     */
	time_t startTime = clock();
	while(clock() < startTime + numOfMilliSec);
}

/*To use the delay just use the command:
  delay(x);
  you need to replace x with the number
  of seconds that you want the delay to
  be.                                    */
  
///The code itself without the details:

#include <time.h>

void delay(int numOfSec)
{
	int numOfMilliSec = 1000 * numOfSec;
	time_t startTime = clock();
	while(clock() < startTime + numOfMilliSec);
}
Posted by: Guest on December-12-2020
-1

c pause for 1 second

#include <stdio.h>
#include <unistd.h> //you need this for linux!
#include <dos.h> //you need this for Windows!

int main(){
    printf("Hello,");
    sleep(5); // format is sleep(x); where x is # of seconds.
    printf("World");
    return 0;
}
Posted by: Guest on June-14-2020
0

c include delay

// for micro programming use(havnt tested in other projects):
#include <delay.h>
Posted by: Guest on May-01-2021

Code answers related to "C"

Browse Popular Code Answers by Language