Given number is little endian or big endian?
#include <stdio.h>
int main()
{
unsigned int n = 1;
char *p;
p = (char*)&n;
if (*p == 1)
printf(“Little Endian\n”);
else if (*(p + sizeof(int) – 1) == 1)
printf(“Big Endian\n”);
else
printf(“Surprise output!!!!\n”);
return 0;
}
Comments