实现应用暂停x毫秒

Posted scruffybear

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实现应用暂停x毫秒相关的知识,希望对你有一定的参考价值。

文章目录

实现应用暂停x毫秒, 测试成功。

#include <iostream>
#include <time.h>

using namespace std;

void sleepcp(int milliseconds);

void sleepcp(int milliseconds) // Cross-platform sleep function

    clock_t time_end;
    time_end = clock() + milliseconds * CLOCKS_PER_SEC/1000;
    while (clock() < time_end)
    
    

int main()

    cout << "Hi! At the count to 3, I'll die! :)" << endl;
    sleepcp(3000);
    cout << "urrrrggghhhh!" << endl;

参考

Sleep for milliseconds

以上是关于实现应用暂停x毫秒的主要内容,如果未能解决你的问题,请参考以下文章