need urgent help!!!!

Vipul Bajaj's Avatar, Join Date: Nov 2006
Newbie Member
I am trying to implement conversion from little endian to big endian on data from a file. the data is such that first 4 bytes give the size of the data adjacent to it. Then I have to convert both the size and the data from little endian to big endian. Then again 4 bytes of size and then data and so on. How to convert the data?
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by Vipul Bajaj
Then I have to convert both the size and the data from little endian to big endian.
For Size it should be same in little as well as big endian.

For data just reverse each chunk of the data.
0
Aztec's Avatar, Join Date: May 2006
Contributor
Quote:
Originally Posted by Vipul Bajaj
I am trying to implement conversion from little endian to big endian on data from a file. the data is such that first 4 bytes give the size of the data adjacent to it. Then I have to convert both the size and the data from little endian to big endian. Then again 4 bytes of size and then data and so on. How to convert the data?
Use ntohl( ) and htonl( )