Q34 Write a program to convert from one Endian to another.

int endian_reverse_fun(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));

}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.