In this post, we will see how to give a time delay in C code. Basic idea is to get current clock and add the required delay to that clock, till current clock is less then required clock run an empty loop.
Here is implementation with a delay function.
This article is contributed by Pratik Chhajer. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- time() function in C
- How to measure time taken by a function in C?
- time.h localtime() function in C with Examples
- time.h header file in C with Examples
- Measure execution time with high precision in C/C++
- C program to print digital clock with current time
- Cvent Interview Experience (On campus for Internship and Full Time)
- C/C++ For loop with Examples
- Arrow operator -> in C/C++ with Examples
- return statement in C/C++ with Examples
- size of char datatype and char array in C
- Logical Not ! operator in C with Examples
- Difference between C and C#
- scanf("%[^\n]s", str) Vs gets(str) in C with Examples