More content will be added soon , if you have any different or better solution then please post in the comment section of the respective question.
Link to understand the concepthttp://www.cs.umass.edu/~verts/cs32/endian.htmlcode to check the machine type :int num = 1;if(*(char *)&num == 1){printf("\nLittle-Endian\n");}else{printf("Big-Endian\n");}code to convert from one Endian to another.int myreversefunc(int num){int byte0, byte1, byte2, byte3;byte0 = (num & x000000FF) >> 0 ;byte1 = (num & x0000FF00) >> 8 ;byte2 = (num & x00FF0000) >> 16 ;byte3 = (num & xFF000000) >> 24 ;return((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | (byte3 << 0));}
Post a Comment
1 comments:
Link to understand the concept
http://www.cs.umass.edu/~verts/cs32/endian.html
code to check the machine type :
int num = 1;
if(*(char *)&num == 1)
{
printf("\nLittle-Endian\n");
}
else
{
printf("Big-Endian\n");
}
code to convert from one Endian to another.
int myreversefunc(int num)
{
int byte0, byte1, byte2, byte3;
byte0 = (num & x000000FF) >> 0 ;
byte1 = (num & x0000FF00) >> 8 ;
byte2 = (num & x00FF0000) >> 16 ;
byte3 = (num & xFF000000) >> 24 ;
return((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | (byte3 << 0));
}
Post a Comment