C语言获取一秒三个状态的代码
以下是一个获取一秒三个状态的C语言代码示例:
#include <stdio.h>
#include <time.h>
int main() {
int i;
for (i = 1; i <= 3; i++) {
printf("State %d\n", i);
sleep(1); // 暂停1秒
}
return 0;
}
这段代码会输出三个状态,每个状态之间间隔1秒。使用sleep(1)函数可以让程序暂停1秒。
原文地址: https://www.cveoy.top/t/topic/hSSu 著作权归作者所有。请勿转载和采集!