谁有BC++的涵数资料(如十进制转BCD码、字符串转BCD码等),请发给我,将不胜感激(100分)

  • 主题发起人 主题发起人 hn_chx
  • 开始时间 开始时间
H

hn_chx

Unregistered / Unconfirmed
GUEST, unregistred user!
谁有BC++的涵数资料(如十进制转BCD码、字符串转BCD码等),请发给我,将不胜感激
tj_nfb@163.net
 
IntToHex(10, 2)
结果是字符串"OA"
下面两个函数是自己写的,
经常用到
String getStrFromHex(unsigned char *str, const int strSize, String tab)
{
char temp[2];
String s;
for (int i = 0;
i < strSize;
i ++)
{
sprintf(temp, "%02x", str);
if (i == 0)
s = s + temp;
else
s = s + tab + temp;
}
return s.UpperCase();
}

bool getHexFromStr(unsigned char *sendStr, int &amp;size, String txtStr)
{
unsigned char char1, char2;
unsigned char *Senddata;
int len;
txtStr.Trim();
len = txtStr.Length();
if (len == 0)
{
MessageBox(NULL,"情输入内容!","出错信息",MB_OK);
return false;
}
Senddata = txtStr.c_str();
size = len / 2;
int i = 0;
for (;
i < size;
i ++)
{
char1 = Senddata[2*i];
char2 = Senddata[2*i + 1];
if(char1>='0'&amp;&amp;
char1<='9')
char1=(char1-'0')*16;
else
if(char1>='a'&amp;&amp;
char1<='f')
char1=((char1-'a')+0x0A)<<4;
else
if(char1>='A'&amp;&amp;
char1<='F')
char1=((char1-'A')+0x0A)<<4;
else
{
MessageBox(NULL,"含非有效数字!","出错信息",MB_OK);
return false;
}
if(char2>='0'&amp;&amp;
char2<='9')
char2=char2-'0';
else
if(char2>='a'&amp;&amp;
char2<='f')
char2=(char2-'a')+0x0A;
else
if(char2>='A'&amp;&amp;
char2<='F')
char2=(char2-'A')+0x0A;
else
{
MessageBox(NULL,"含非有效数字!","出错信息",MB_OK);
return false;
}
sendStr=char1+char2;
}
return true;
}
 
后退
顶部