蜂鸣声 printf("/a");
time_t 以秒表示时间,可以转换为下面的结构
struct tm
{
int tm_sec; /* (0 - 61) */
int tm_min; /* (0 - 59) */
int tm_hour; /* (0 - 23) */
int tm_mday; /* (1 - 31) */
int tm_mon; /* (0 - 11) */
int tm_year; /* past 1900 */
int tm_wday; /* (0 - 6) */
int tm_yday; /* (0 - 365) */
int tm_isdst; /* daylight savings flag */
};
time_t tval = time(NULL);
struct tm * now = localtime(&tval);
printf("The current date and time:/n"
"%d/%02d/%02d %d:%02d:%02d/n/n",
now->tm_mon+1, now->tm_mday, now->tm_year,
now->tm_hour, now->tm_min, now->tm_sec);
上面%02d 当为个位数,可以左边补零
tval=mktime(now);
asctime(now) 得到字符串表示的时间
ctime(tval) 得到字符串表示的时间
本文介绍了C语言中如何使用time_t和struct tm进行时间日期的获取与格式化输出,并展示了蜂鸣声的输出方法。

880

被折叠的 条评论
为什么被折叠?



