Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   need urgent help!!!! (http://www.go4expert.com/forums/need-urgent-help-t1824/)

Vipul Bajaj 7Nov2006 13:26

need urgent help!!!!
 
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?

shabbir 7Nov2006 15:08

Re: need urgent help!!!!
 
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.

Aztec 7Nov2006 22:38

Re: need urgent help!!!!
 
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( )


All times are GMT +5.5. The time now is 15:20.