Want a Free Job Posting?

Buy a job posting today and the second one is on us. For a limited time only. Act Now.

Interview Question


how to detect the system is big endian or little endian


Interview Answer

1 Answer


int is_big_endian () { int foo; char *p; foo = 0x12345678; p = (char*)& foo; if (*p == 0x12) { return 1; } else { /* 0x78 */ return 0; } }

Brian on Oct 13, 2009

Add Answers or Comments

To comment on this, Sign In or Sign Up.