c/c++获取系统时间

#include   
#include 
#include 
int main()
{
    /*
    typedef struct _SYSTEMTIME {
        WORD wYear;
        WORD wMonth;
        WORD wDayOfWeek;
        WORD wDay;
        WORD wHour;
        WORD wMinute;
        WORD wSecond;
        WORD wMilliseconds;
    } SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
    */
    SYSTEMTIME Time;
    GetLocalTime(&Time);
    std::cout << Time.wYear << "年"
        << Time.wMonth << "月"
        << Time.wDay << "号"
        << Time.wHour << "点"
        << Time.wMinute << "分"
        << Time.wSecond << "秒"
        << Time.wMilliseconds << "毫秒"
        << std::endl;

    std::string week[7] = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
    std::cout << week[Time.wDayOfWeek] << std::endl;
    system("pause");
    return 0;
}

你可能感兴趣的:(c,c++)