unsigned char 与unsigned long互换

Posted 一生不过烟花

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了unsigned char 与unsigned long互换相关的知识,希望对你有一定的参考价值。

unsigned long UCharToULong(unsigned char * pucVar )
{
unsigned long ulTemp=0;
ulTemp=(unsigned long)(*pucVar);
ulTemp<<=8;
pucVar++;
ulTemp|=(unsigned long)(*pucVar);
return ulTemp;
}
void ULongToUChar(unsigned char * pucVar,unsigned long ulVar)
{
unsigned short usVar;
usVar=(unsigned short)ulVar;
*pucVar=(unsigned char)(usVar>>8);
pucVar++;
*pucVar=(unsigned char)usVar;
}

以上是关于unsigned char 与unsigned long互换的主要内容,如果未能解决你的问题,请参考以下文章

std::string 与 unsigned char[] 和 unsigned char* 有啥不同?

数据库unsigned char*类型图片存进

关于unsigned char 型数据转换成十进制或者16进制的问题

cv::mat与unsigned char*相互转化之间的转换

char和unsigned char--数据类型区别

用unsigned char 表示字节