Posted By

brianyang on 02/07/11


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

albertomori


Write a function that determines whether a computer is big-endian or little-endian.


 / Published in: C++
 

Returns true if the machine is little-endian, false if the * machine is big-endian

  1. bool endianness(){
  2. union {
  3. int theInteger;
  4. char singleByte;
  5. } endianTest;
  6. endianTest.theInteger = 1;
  7. return endianTest.singleByte;
  8. }

Report this snippet  

You need to login to post a comment.