zoukankan      html  css  js  c++  java
  • byte数组之间的赋值,byte和TCHAR数组的赋值

          第一步很关键,给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;
    }




  • 相关阅读:
    实现一个最简单的flask应用程序
    python常识
    Flex布局
    ES6的promise的学习
    通过正则获取url参数
    dom0级事件和dom2级事件
    sea.js总结
    跨域的几种方式
    人生苦短,生命也就一次,机会也就一次
    新开的博客先和大家打个招呼吧!
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3071918.html
Copyright © 2011-2022 走看看