为了账号安全,请及时绑定邮箱和手机立即绑定

C语言关于localtime_s()和asctime_s()两个函数的用法?

C语言关于localtime_s()和asctime_s()两个函数的用法?

holdtom 2019-02-13 15:11:20
请问一下 你的这个问题最后是怎么解决的。我现在用vs2013第一次写带有时间的代码,也碰到说localtime_s未初始化的现象 求教解决方法。
查看完整描述

2 回答

?
qq_花开花谢_0

TA贡献1835条经验 获得超6个赞

123456789101112131415161718192021222324252627282930#include <stdio.h>#include <time.h> #define TIME_MAX 32 void get_time(void); int main(){  get_time();  getchar();  return 0;} void get_time(void){  time_t now;  time(&now);   // 定义两个变量,存储转换结果  struct tm tmTmp;  char stTmp[TIME_MAX];   // 转换为tm结构  localtime_s(&tmTmp,&now);   // 转换为字符串并输出  asctime_s(stTmp,&tmTmp);  printf("Current time is: %s\n",stTmp);}


查看完整回答
反对 回复 2019-03-22
  • 2 回答
  • 0 关注
  • 1218 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信