Ubuntu系统下sleep函数头文件
在Ubuntu系统下,使用sleep函数需要包含头文件<unistd.h>。
示例代码如下:
#include <stdio.h>
#include <unistd.h>
int main() {
printf("Sleeping for 5 seconds...\n");
sleep(5);
printf("Awake!\n");
return 0;
}
编译并运行该代码,将会在终端中打印出"Sleeping for 5 seconds...",然后等待5秒后打印出"Awake!"。
原文地址: https://www.cveoy.top/t/topic/hHVZ 著作权归作者所有。请勿转载和采集!