time

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

int main()
{
    time_t start;
    time_t end;

    time(&start);  // 1970 年 1 月 1 日 0 时 0 分 0 秒 至今的秒数
    for (int i = 0; i < 10; i++)
    {
        Sleep(1000);
    }
    time(&end);

    std::cout << "using " << end - start << "seconds" << std::endl;

    return 0;
}

image

参考:http://www.cplusplus.com/reference/ctime/time/

posted @ 2022-04-16 21:00  荒年、  阅读(36)  评论(0编辑  收藏  举报