ma***********@web.de (glueless) writes:
I have to read files from UNIX systems on my PC. The problem
is that these binary files are in big endian and I need to convert
them. I saw that there are functions ntohl for my visual C++ (4.0),
but I don't know in what librarieses these are.
I want to kep the code as simple as possible, since I also want to
compile it on UNIX systems. Does anyone know of existing functions
that do the conversion as I am a bit lazy to program thi myself?
It depends on the file format. If the files are just, say, a whole
bunch of 32-bit integers catenated together, it shouldn't be too hard.
If, on the other hand, the files contain a mixture of date types
(e.g., the content is effectively an array of structures, where some
of the members are character strings, others are integer, etc.), it's
going to be a bit more difficult. If they contain variable-sized
records, it's going to be even more difficult.
Your best bet might be write a program that reads in the binary file
and generates an unambiguous textual representation, and another that
reads in the textual representation and generates a binary file.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"