converting a 64 bit number from little indian to big indian

#includelong long int INT_little_endian_TO_big_endian(long long int i){ return (((i&0xff)8)&0xff000000)|((i24)&0xff0000)|((i40)&0xff00)|((i56)&0xff));}int main(){ long long int num = 1,rev; if(*(char *)&num == 1) //if num is odd,compare with 1 other wise compare with 0{ printf(”
Little-Endian
“); printf(“%d”,sizeof(num));}else { printf(“Big-Endian
“);}rev=INT_little_endian_TO_big_endian(num);printf(“%lld
“,rev);return 0;}

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Related Posts