简单有关问题,数据类型转换的有关问题.非常感谢

简单问题,数据类型转换的问题.非常感谢.
VisualEleven老大给了一段代码,再次感谢.
想改成一个自定义函数GetDataTest,返回的值的类型和形式要和 
BYTE test[16]={0x02, 0x00, 0x01, 0x02,
  0x00, 0x01, 0x01, 0x08,}

一样. 哪位给指导一下.非常感谢.

C/C++ code

#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;
}





------解决方案--------------------
- '0' 就是 减 0x30,由'3' 变成 3。

“2012”,这个'2'在内存就是0x32,要转成2,就减去0x30

------解决方案--------------------
- '0' 就是 减 0x30,由'3' 变成 3。

“2012”,这个'2'在内存就是0x32,要转成2,就减去0x30