How to Delay in C
Did you ever want to make a C program wait for a certain time? You can set up a technique to allow time to tick away, for example: when showing a splash page (a notice or hint) for a game. Okay, here are some ways to make the program...
Table of Contents
Method 1 of 2:
The "for-loop" technique
-
Use a typical "for" loop followed by a null statement to implement time delay. -
Write as follows, for an example:- for (i=1 ; i
- The statement followed by the ";" makes the computer execute the loop 100 times without any noticeable event. It just creates a time delay.
Method 2 of 2:
The "sleep()" Technique
-
Use sleep() The function called sleep(int ms) declared in which makes the program wait for the time in milliseconds specified. -
Include the following line in your program before "int main()":- #include
-
Insert, wherever you need your program to make a delay:- sleep(1000);
- Change the "1000" to the number of milliseconds you want to wait (for example, if you want to make a 2 second delay, replace it with "2000".
- Tip: On some systems the value might refer to seconds, instead of milliseconds. So sometimes 1000 isn't one second, but, in fact, 1000 seconds.
You've just finished reading the article "How to Delay in C" edited by the TipsMake team. You can save how-to-delay-in-c.pdf to your computer here to read later or print it out. We hope this article has provided you with many useful tech tips and tricks. You can search for similar articles on tips and guides. Thank you for reading and for following us regularly.
Read More
- How to disable Startup Delay in Windows 10
- How to delay starting OneDrive on Windows 10/8/7
- 9 Ways to Fix Keyboard Typing Delay on Windows 10/11
- How to change Windows 11 keyboard character repeat delay
- How to delay program startup with Task Scheduler on Windows 10/8/7
- Alt + Tab delay and 5+ quick and easy ways to fix it
- Instructions for scheduling sending emails and delaying sending emails in Outlook
- Bluetooth Headset Sound Delay When Playing Games - Solution
- World's fastest robot boxer, response delay less than 1/15 blink time
- How to change, prolong the delay of updating on Windows 10?
- How to Start Scheduled Tasks with Delay on Windows
- Samsung only allows users to delay software updates up to 10 times
- Buying a Windows laptop is harder than ever
- One UI 7 still can't be deployed because of Samsung's mistake




