I want to write program for implementing long time (200ms) delay in execution of loop in C language, can you give some good advice? Is that any syntax to put put a delay of milliseconds or seconds at any step in a C program.
I want to write program for implementing long time (200ms) delay in execution of loop in C language, can you give some good advice? Is that any syntax to put put a delay of milliseconds or seconds at any step in a C program.
Creating a software loop to generate time delays in C for each loop which delay the execution. You could try something like :
Code:for (i=0;i<35;i++) { j=i; }
You probably want to use usleep(microseconds) : > #include <windows.h> and use > Sleep(ms). *note the capital S*. In C Programming both Sleep(), sleep(), and SleepEx() all pause for milliseconds.
Delay for 10 seconds example
Code:#include <stdio.h> #include <time.h> int main() { time_t start; time_t current; time(&start); printf("delay for 10 seconds.\n"); do{ time(¤t); }while(difftime(current,start) < 10.0); printf("Finished delay.\n"); return 0; }
Bookmarks