Pages
Home
VijayNetwork
C Programming Q&A
Friday, January 13, 2012
How to find the 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;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment