以下给出一段写log时非常有用的代码,取得系统的当前时间, 之前看到我的parter写服务器的log竟然没有写上时间,狂晕,symbian下写log就爽多了,自动加上时间的.
char times[50];
memset(times,'/0',50);
struct tm *local;
time_t t;
t=time(NULL);
local=localtime(&t);
sprintf(times,"%d年%d月%d日%d时%d分",local->tm_year+1900,local->tm_mon+1,local->tm_mday,local->tm_hour,local->tm_min);
有时会报错
可能是有变量命名为time了,与这里的t=time(NULL);冲突
将这个变量改名字就行了
本文介绍了一段用于记录Symbian系统日志的实用代码,该代码能够获取并格式化当前时间,方便地添加到日志中。由于Symbian系统自带的日志功能已包含时间戳,故本文主要适用于其他需要手动添加时间信息的环境。
1万+

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



