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