BYTE* TurnToBYTE(const char* pStr,int & ampnArraySize)
{
//Calculate the size of the byte array. If the string length is odd, you need to increase 1 bit.
int nLength = strlen(pStr);
int nSize =(nLength/2)+(nLength % 2);
nArraySize = nSize
//Initializes a byte array.
BYTE * SZ BYTE =(BYTE *)malloc(nSize * sizeof(BYTE));
memset( szBYTE,0,(nSize * sizeof(BYTE)));
//Write 2 characters at a time.
for(int I = 0; I & ltnSizei++)
{
char SZ temp[3]= { 0 };
SZ temp[0]= * pstr++;
if (*pStr! = '\0')
{
SZ temp[ 1]= * pstr++;
}
//Use atoi to convert the char pointer into a numerical value and store it in the current array element.
int nn number = atoi(SZ temp);
SZ byte[I]= n number;
}
Return szBYTE
}
void main()
{
int nSize = 0;
BYTE* psz = TurnToBYTE(" 123 ",nSize);
for(int I = 0; I & ltnSizei++)
{
int n number =(int)PSZ[I];
cout & lt& ltnNumber & lt& lt"_";
}
cout & lt& ltendl
Free of charge (PSZ);
psz = NULL
}