打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
C获取当前时间
from http://www.cnblogs.com/wainiwann/p/4702465.html
2015.08
#include <stdio.h>
#include <time.h>
#include <string>
#include <windows.h>
using namespace std;

 
void main(){
    //精确到秒    time_t rawtime;
    struct tm * timeinfo;
    time ( &rawtime );
    timeinfo = localtime ( &rawtime );
    char imgeName[255] = {0};
    sprintf(imgeName,
        "当前时间:%4d %02d %02d %02d %02d %02d",
        1900+timeinfo->tm_year,
        1+timeinfo->tm_mon,
        timeinfo->tm_mday,
        timeinfo->tm_hour,
        timeinfo->tm_min,
        timeinfo->tm_sec); 
//imgeName = 0x00d4f908 "当前时间:20150804164416"        //精确到毫秒
    SYSTEMTIME currentTime;
    GetSystemTime(&currentTime);
    printf("time:  %u /%u /%u  %u: %u: %u: %u  %d \n",  
              currentTime.wYear,currentTime.wMonth,currentTime.wDay,
    currentTime.wHour,currentTime.wMinute,currentTime.wSecond,
    currentTime.wMilliseconds,currentTime.wDayOfWeek);
    /*    wYear    2015    unsigned short
    wMonth    8    unsigned short
    wDayOfWeek    2    unsigned short
    wDay    4    unsigned short
    wHour    9    unsigned short
    wMinute    31    unsigned short
    wSecond    33    unsigned short
    wMilliseconds    149    unsigned short
    */
        exit(0);}

 

参考:http://zhidao.baidu.com/link?url=NhiAk1VJdL0X6abaisbuvFy7BmuaWLwp4-TedKdGp045XqXKWIMKnpukvyxsK4DxORdzHkoU_y_iHxQP3GD5-q

http://blog.csdn.net/witxjp/article/details/8079751

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
C语言获取系统当前时间
setlocale
关于MTK socket编程的一些经验
以太网帧、IP 帧、UDP/TCP帧、http 报文结构解析
Linux下串口编程
%02hhX
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服