It was thus said that the Great Andreas Holz once stated:
Christopher,
some questions to your program:
what does the statement do:
read(infile,&reclen,4); ?
this syntax does not conform to UNIX (POSIX) read (e.g. HP/UX):
ssize_t read(int filedes, void *buf, size_t nbyte);
It does. It reads in four bytes from infile and stores them in reclen (of
which a pointer is given to read() and in ANSI C, any pointer can be cast to
void *). The bug lies in how integers are written. If, for instance, the
data was written on a little-endian system and then you attempt to read on a
big-endian system you are not going to get consistent results. You need to
ensure a consistent ordering of bytes.
-spc (htonl() and ntohl() are your friends 8-)