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 firstname.lastname@example.org. 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 header file in C with Examples
- time.h localtime() function 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)
- Difference between Increment and Decrement Operators
- Problem in comparing Floating point numbers and how to compare them correctly?
- exit(0) vs exit(1) in C/C++ with Examples
- Predefined Macros in C with Examples
- How to create GUI in C programming using GTK Toolkit
- ctype.h(<cctype>) library in C/C++ with Examples
- Slack Bytes in Structures : Explained with Example
Improved By : ManasChhabra2