0

I have a binary file which contains about 2 bytes of data. I am trying to read this data and convert it into hexadecimal and then store it into an unsigned character array. I am currently able to read the binary data, but I am not sure how to convert it into hex and store it into an unsigned char array(All the data read from binary will correspond from 1-9 in Hex). So if the binary data was 00011000 00011000 I would want the unsigned char to be {18,18}. How do I go about converting to hex and then storing it into an unsigned char? This is what I have as of now:

FILE *binaryFile = fopen("securityFile","rb");//type binary file
        char hexData[2];
        fread(hexData,1,2,binaryFile);
0

1 Answer 1

1

use sprintf (or snprintf). see http://libslack.org/manpages/snprintf.3.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.