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]);
	}
}

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