C语言16进制数怎么转换成时间
例如8C 82 BF 40,怎么转换成日期时间的格式输出,谢谢了
[解决办法]
- C/C++ code
#include <stdio.h>#include <time.h>char h[]="8C 82 BF 40";int b;unsigned char *p;int i,v;struct tm *t;void main() { p=(unsigned char *)&b; for (i=0;i<4;i++) { sscanf(h+3*i,"%2X",&v); p[i]=(unsigned char)(v&0xFFu); } t=localtime((const time_t *)&b); printf("%s\n",asctime(t));}//Fri Jun 04 03:57:00 2004