《c primer plus第六版》clock和ctime创建延迟循环
作者:yunjinqi   类别:    日期:2023-10-06 10:56:51    阅读:123 次   消耗积分:0 分    

最近在看c++ primer plus第六版,虽然学了很久的c++了,看这本经典书依然有收获。

碰到一个有意思的程序,记录一下。

#include <iostream>
#include <ctime>

int main(){
std::cout << "Enter the delay time, in seconds" << std::endl;
float seconds;
std::cin >> seconds;
clock_t delay = seconds*CLOCKS_PER_SEC;
std::cout << "starting \n" ;
clock_t start = clock();
while (clock()-start<delay){

}
std::cout << "done\n";
return 0;

}


版权所有,转载本站文章请注明出处:云子量化, http://www.woniunote.com/article/332
上一篇:c语言编程练习题:7-207 机工士姆斯塔迪奥
下一篇:arrow系列1 --- arrow 是什么