Alex Rivera | Logout

How to check whether a system is big endian or little endian?

Asked 2010-11-15T06:29:26.587
120

How to check whether a system is big endian or little endian?

Edit
Report

1 Answer

129

In C, C++

int n = 1;
// little endian if true
if(*(char *)&n == 1) {...}

See also: Perl version

answered 2010-11-15T06:36:30.830

Your Answer