c 语言延时函数

 

/*--- 等待x毫秒 ---*/
int sleep(unsigned long x)
{
    clock_t c1 = clock(), c2;

    do {
        if ((c2 = clock()) == (clock_t)-1)    /* 错误 */
            return 0;
    } while (1000.0 * (c2 - c1) / CLOCKS_PER_SEC < x);
    return 1;
}

 

posted @ 2019-06-17 00:39  anobscureretreat  阅读(1947)  评论(0编辑  收藏  举报