Is there a better way from hex to char?
char one = static_cast<char>(0x01);
(asking because of this –> C++ using pointers, nothing is passed )
Also is there a fast way to make a char array out of hex values (eg. 0x12345678 to a char array)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can try this:
Credits to STL for the “index into char array” trick.
Also beware when printing
chars, which are signed on some platforms. If you want128to print as80rather thanFFFFFFFF, you have to prevent it from being treated as-1by converting to unsigned char first:hexify((unsigned char)(c));