unsigned char数组赋值


memset(send_buf, 0, SEND_BUFF_LEN);

const char * pStr = "this is test txt";
strcpy((char*)send_buf,pStr);

 

 

unsigned char数组 赋值与长度unsigned char数组 赋值与长度

unsigned char数组 赋值与长度unsigned char数组 赋值与长度unsigned char数组 赋值与长度

 

//重要的事情 说5遍

unsigned char toByte(char c)
{
	unsigned char value = 0;

	if (c >= '0' && c <= '9')
		value = c - '0';
	else if (c >= 'A' && c <= 'Z')
		value = c - 'A' + 10;
	else if (c >= 'a' && c <= 'z')
		value = c - 'a' + 10;

	return value;
}

void hexStringToByte(unsigned char *dstByte,const char *srcHexString ,int len)
{
	int index;

	for (int i = 0; i < len; i++){
		index = i * 2;
		dstByte[i] = ((toByte(srcHexString[index]))<<4) | toByte(srcHexString[index+1]);
	}
}

  输入可以,如何计算长度???????????????????????????????????


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM