Receive our weekly advanced programming tips for FREE
19.April
To see wich endian is beeing used
0
| 0 votes
Autor: bookkeeper
Chapter: C++

Every CPU stores the bits over one byte in special order like the number. Here is the code to see wich endian your cpu use.

#include 

/*
Test for endian

4321 = Big endian
1234 = Little endian
3412 = Middle endian
*/

int main()
{
 int n = 0x04030201;
 char *s = (char*)(void *)&n;

 printf("%d%d%d%d\n", s[0], s[1], s[2], s[3]);

 return 0;
}