2 回答
TA贡献1873条经验 获得超9个赞
#include<stdio.h>
#include<Windows.h>
int main()
{
SYSTEMTIME st;
GetLocalTime(&st);
printf("%d点%d分%d秒%d毫秒\n",st.wHour,st.wMinute,st.wSecond,st.wMilliseconds); 
return 0;
}
TA贡献1829条经验 获得超13个赞
#include <stdio.h>  
#include <time.h>  
int main()
{  
time_t rawtime;  
struct tm * timeinfo;  
time ( &rawtime );  
timeinfo = localtime ( &rawtime );  
printf ( "The current date/time is: %s", asctime (timeinfo) );
return 0;
}
说明:
time_t // 时间类型(time.h 定义)  
struct tm { // 时间结构,time.h 定义如下:  
int tm_sec;  
int tm_min;  
int tm_hour;  
int tm_mday;  
int tm_mon;  
int tm_year;  
int tm_wday;  
int tm_yday;  
int tm_isdst;  
}  
time ( &rawtime ); // 获取时间,以秒计,从1970年1月一日起算,存于rawtime  
localtime ( &rawtime ); //转为当地时间,tm 时间结构  
asctime() // 转为标准ASCII时间格式:  
//就是直接打印tm,tm_year 从1900年计算,所以要加1900,月tm_mon,从0计算,所以要加1
- 2 回答
 - 0 关注
 - 223 浏览
 
添加回答
举报
