#include #include using namespace std; union endian_check { int number; char check; }; int main(int argc, char** argv) { endian_check _check; _check.number = 1; // Check the valu of the least significant byte. if (_check.check) cout << "little endian" << endl; else cout << "big endian" << endl; return EXIT_SUCCESS; }