time(0)转化成时间

#include<stdio.h>
#include<time.h> 
#include<windows.h>
using namespace std;
int main() {
    long long seconds;
    int h, m, s;
    while (1) {
        //system("cls");
        seconds = time(0);
        s = seconds % 60;
        m = (seconds % 3600) / 60;
        h = (seconds % (3600 * 24)) / 3600 + 8;
        h %= 24;
        printf("%02d:%02d:%02d\r", h, m, s);
        //Sleep(1000);  
    }   
    return 0;
}

猜你喜欢

转载自blog.csdn.net/henuyh/article/details/80279840