猿问
回到首页
个人中心
反馈问题
注册登录
下载APP
首页
课程
实战
体系课
手记
专栏
慕课教程
请问我该怎么打印输出时分秒毫秒?
求大神,怎么样输出毫秒,比如14:10:12:5 14点10分12秒5毫秒
守候你守候我
浏览 219
回答 2
2回答
眼眸繁星
#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;}
0
0
0
烙印99
#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
0
0
0
打开App,查看更多内容
随时随地看视频
慕课网APP
相关分类
C
typedef入门问题
5 回答
继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续