byte数组之间的赋值,byte和TCHAR数组的赋值
2013-05-10 09:42
281 查看
第一步很关键,给byte数组赋值,
byte tzi[2][44] =
{
0xD0,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x94,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};必须是以0x的方式开头,表示类型为字节,否则以L“”,这种赋值,会变为ASCII码的形式,
将byte* 赋值给byte* ,利用memcpy(),进行赋值即可。
将TChar*赋值给 byte*
int StrToBin(TCHAR* inWord, BYTE* OutBin, int source_len)
{
int t;
int t2;
int count = 0;
BYTE temBin[2];
temBin[0] = 1;
temBin[1] = 1;
if (source_len < 1)
return 0;
for(t = 0 ;t < source_len; t ++)
{
t2 = inWord[t];
if( t2 > 127 )
{
temBin[0] = t2 >> 8 ;/// 256;
temBin[1] = t2;
OutBin[count] = temBin[0];
count += 1;
OutBin[count] = temBin[1];
count += 1;
}
else
{
OutBin[count] = t2;
count += 1;
}
}
return count;
}
byte tzi[2][44] =
{
0xD0,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x94,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};必须是以0x的方式开头,表示类型为字节,否则以L“”,这种赋值,会变为ASCII码的形式,
将byte* 赋值给byte* ,利用memcpy(),进行赋值即可。
将TChar*赋值给 byte*
int StrToBin(TCHAR* inWord, BYTE* OutBin, int source_len)
{
int t;
int t2;
int count = 0;
BYTE temBin[2];
temBin[0] = 1;
temBin[1] = 1;
if (source_len < 1)
return 0;
for(t = 0 ;t < source_len; t ++)
{
t2 = inWord[t];
if( t2 > 127 )
{
temBin[0] = t2 >> 8 ;/// 256;
temBin[1] = t2;
OutBin[count] = temBin[0];
count += 1;
OutBin[count] = temBin[1];
count += 1;
}
else
{
OutBin[count] = t2;
count += 1;
}
}
return count;
}
相关文章推荐
- byte数组之间的赋值,byte和TCHAR数组的赋值
- 动态生成数组,数组之间赋值
- 十六进制字符串和byte数组之间的各种转换关系
- InputStream,int,shot,long与byte数组之间的互相转换
- Java中byte[]数组和int之间的转换
- java整数和byte数组之间的转换
- InputStream String与byte数组之间的互转
- Android学习 之 Bitmap Drawable byte[] 三者之间的转换以及把数组存入数据库及提取数据重新组合成所需对象,如图像
- [转]java中long,int,short与byte数组之间的转换
- 为什么内置数组类型不支持数组之间的赋值?
- java中long,int,short与byte数组之间的转换
- Int型和byte数组,以及long型和byte数组之间的相互转换
- 整型数和网络字节序的byte[] 数组之间的转换
- java中byte数组与int类型之间的相互转换(两种方式)
- 关于字符串和byte数组在java和ios之间兼容的解决办法。
- byte数组和其他数据类型之间的转化
- byte[]数组和int之间的转换
- byte[]数组和int之间的转换
- Java中byte数组与short,int,char,long,float,double之间的转换
- byte[]数组和int之间的转换