欢迎来到山村网

c++实现每隔1秒钟执行一段程序

2019-03-02 09:46:28浏览:392 来源:山村网   
核心摘要:#include iostream#include ctimeusing namespace std;int getTime() {return clock()/CLOCKS_PER_SEC;}int main() {int i = 0;i

#include <iostream>
#include <ctime>
using namespace std;

int getTime() {
return clock()/CLOCKS_PER_SEC;
}

int main() {
int i = 0;
int lastTime = 0;
while (1) {
int now = getTime();
if (now - lastTime > 0) {
cout << ++i << endl;
lastTime = now;
}
}
return 0;
}

(责任编辑:豆豆)
下一篇:

C#预处理指令之#line、#pragma warning

上一篇:

10个技能让你成为一位好的Web开发人员

  • 信息二维码

    手机看新闻

  • 分享到
打赏
免责声明
• 
本文仅代表作者个人观点,本站未对其内容进行核实,请读者仅做参考,如若文中涉及有违公德、触犯法律的内容,一经发现,立即删除,作者需自行承担相应责任。涉及到版权或其他问题,请及时联系我们 xfptx@outlook.com