将short类型转换为char类型

void short2char(uint8_t *arr1, uint16_t *arr2, int len)

{

    int x = 0;

    int y = 0;

    for (x; x < len; x++)

    {

        arr1[x++] = arr2[y] >> 8;

        if (2 * y + 1 >= len)

            continue;



        arr1[x] = (arr2[y++]) & 0xff;

    }

}

猜你喜欢

转载自www.cnblogs.com/bliss-/p/12377453.html
今日推荐