[comp.lang.c] Binary file compitability

siping@cathedral.cerc.wvu.wvnet.edu (Siping Liu) (01/08/91)

Can someone tell me how to read (in c code) a binary file which was
writen on a different structured machine/OS?
I know I can use functions like htonl, htons, etc to partly solve this
problem (My program running on sun4 can read a binary file writen on
a VAX 3200. The file contains some values of integer and float types).

But I do not know how to translate a value of the type "double" to/from
the network format. Even though htonl/ntohl works fine, they were not used for
this kind of purpose but for simplifying the manipulation of names and
addresses on the network. I am kind of expecting to find something like
"hton_int", "hton_float", etc. type-oriented translation routines.

Thanks in advance.

Siping Liu.
siping@cerc.wvu.wvnet.edu