0

I'm using a code snippet like the following (from this question):

char const hex_chars[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };

for( int i = data; i < data_length; ++i )
{
  char const byte = data[i];

  string += hex_chars[ ( byte & 0xF0 ) >> 4 ];
  string += hex_chars[ ( byte & 0x0F ) >> 0 ];
}

It works; however, it produces a string like F0000000 (for example).

Firstly, what endianness is this?

Secondly, how could I change the code to change the endianness of the output?

Thank you very much in advance.

2
  • Sorry, I should've included this. string is a std::string, data is an array of chars and data_length == 4. Commented Feb 28, 2015 at 5:01
  • It's not any endianness. Endianness is not applicable to the code you posted. Commented Feb 28, 2015 at 5:23

0

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.