Skip to content

Instantly share code, notes, and snippets.

@ls0f
Created August 31, 2015 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ls0f/b3cd23e5f87f52373cf5 to your computer and use it in GitHub Desktop.
Save ls0f/b3cd23e5f87f52373cf5 to your computer and use it in GitHub Desktop.
查看机器是大端还是小段
#include<stdio.h>
typedef unsigned char * byte_pointer;
int showBigOrLittleEnd()
{
int i = 0x01;
byte_pointer bp = (byte_pointer) &i;
if (bp[0] == 0x01)
return 1;
else
return 0;
}
void main()
{
if (showBigOrLittleEnd() == 1)
printf("little end\n");
else
printf("big end\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment