Home >Backend Development >C#.Net Tutorial >How to pause the execution of C language program
How to pause the execution of a C language program
In C language programming, you can pause the execution of the program by using the following function:
sleep()
sleep()
The function will pause the program for the specified number of seconds. Its prototype is:
<code class="c">#include <unistd.h> unsigned int sleep(unsigned int seconds);</code>
where, The seconds
parameter specifies the number of seconds to pause. After the function call is successful, the program will pause execution and wait for the specified time.
Steps to pause the program:
<unistd.h>
sleep()
function to pause program execution. Example:
<code class="c">#include <stdio.h> #include <unistd.h> int main() { printf("这个程序将会暂停 5 秒。\n"); sleep(5); printf("程序已恢复执行。\n"); return 0; }</code>
Output:
<code>这个程序将会暂停 5 秒。 (5 秒暂停) 程序已恢复执行。</code>
The above is the detailed content of How to pause the execution of C language program. For more information, please follow other related articles on the PHP Chinese website!