0
Char array into single char C++
Letâs say we have an array: unsigned char array[]={â1â, â5â, â3â} This elements are acording to ASCII 0x31, 0x35, 0x33 And i need to make a single number out of those elements 0x313533 Does anyone had any idea how can I add them like that???
2 Answers
+ 2
The shortest approach I can think of is to use a stringstream, since it can automatically assume a hexadecimal base for its operations. Here is an example:
https://code.sololearn.com/cQ0nMK434pqp/?ref=app
Otherwise, you would probably have to do the conversion yourself, i.e. from char to decimal to hex, followed by a concatenation of the values.
0
Nice!