我正在研究一個Arduino項目,並且希望將十六進制值存儲爲字符串。將十六進制值存儲爲字符串(Arduino項目)
如:十六進制是C697C63B
for (byte i = 0; i < bufferSize; i++) {
Serial.print(buffer[i], HEX);
}
我想字符串存儲爲x = "C697C63B";
String CardID = "";
for (byte i = 0; i < bufferSize; i++) {
CardID += (buffer[i],HEX);
Serial.println(CardID);
}
但斯汀存儲爲CardID = 16161616
對不起,我剛開始C++的一週,我花了3天才找到答案。
好吧,我找到了答案,現在謝謝大家,幫
String CardID = "";
for (byte i = 0; i < bufferSize; i++)
CardID += String(buffer[i], HEX);
Serial.print(CardID);
'CardId中+ =(緩衝[I],HEX);'沒有做什麼,你認爲它。請閱讀[逗號運算符](http://stackoverflow.com/questions/54142/how-does-the-comma-operator-work)。另外,你需要提供[mcve]。 –