unsigned char的问题
DllExport int SetNowTime(char *timestr)
{
unsigned char datetime[14];
memset(datetime,0,14);
int j =0;
for(int i=0;i <28;i++)
{
if(0 == i%2)
{
datetime[j] = timestr[i];
j++;
}
}
//此时 datetime[]=06071231100000
int st;
//年、星期、月、日、时、分、秒 06071231100000 06年 星期天 12月31日 10点整
//unsigned char datetime1[] = {0x06,0x05,0x12,0x29,0x09,0x59,0x10};
.......
return 0;
}
请教:
如何把datetime[]=06071231100000 转换成unsigned char datetime1[] = {0x06,0x05,0x12,0x29,0x09,0x59,0x10}这种格式
[解决办法]
这个函数可以转换字符串wsprintf
格式化字符串用 %02x
[解决办法]
datetime[]=06071231100000 转换成unsigned char datetime1[] = {0x06,0x05,0x12,0x29,0x09,0x59,0x10}这种格式
------------------------
这种转换是没有意义的,因为每个元素都会被截断。