16,472
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <Windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
SYSTEMTIME systime;
GetLocalTime(&systime);
TCHAR szBuf[10] = {0};
_stprintf_s(szBuf, _countof(szBuf), _T("%04d%02d%02d"), systime.wYear, systime.wMonth, systime.wDay);
int len = _tcslen(szBuf);
BYTE* pData = new BYTE[len];
memset(pData, 0, len * sizeof(BYTE));
for(int i=0; i<len; i++)
{
pData[i] = szBuf[i] - 0x30;
}
TCHAR buf[256] = {0};
TCHAR tmp[10] = {0};
for(int i=0; i<len; i++)
{
_stprintf_s(tmp, _countof(tmp), _T("0x%02x, "), pData[i]);
_tcscat_s(buf, _countof(buf) - _tcslen(buf), tmp);
}
_tprintf(_T("%s\n"), buf);
return 0;
}
#include "stdafx.h"
#include <Windows.h>
#include "tchar.h"
int main(int argc, char* argv[])
{
SYSTEMTIME systime;
GetLocalTime(&systime);
TCHAR szBuf[10] = {0};
_stprintf(szBuf, _T("%04d%02d%02d"), systime.wYear, systime.wMonth, systime.wDay);
unsigned char test[ 8 ];
int i;
for( i = 0; i < 8; i++ )
{
test[ i ] = szBuf[ i ] - '0';
}
return 0;
}