#include <stdio.h>
//判断程序运行的平台是little-endian还是big-endian
bool IsLittleEndian()
{
int i = 1;
char* p = (char*)&i;
return *p;
}
int main()
{
if(IsLittleEndian())
printf("LittleEndian\n");
else
printf("BigEndian\n");
return 0;
}
big-endian The most significant byte is on the left end of a word.
little-endian The most significant byte is on the right end of a word.
example:
big: [1000]4F,[1001]52 表示4f52
little: [1000]52,[1001]4f 表示4f52
3. Converting Small endian to Big Endian using C#(long value)