Date: Sat, 10 Oct 1998 20:21:41 +0100 (BST) From: George Foot To: djgpp AT delorie DOT com Subject: Re: newbie: endianess In-Reply-To: <6vo51m$ti1$1@news3.tufts.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com On 10 Oct 1998, Sigurdur Smarason wrote: > Right now I swap the bytes after I read them or before I write them, but > it is becoming more complicated to do so as the program evolves, I'm > starting to wonder how complicated is it to overload the fopen in DJGPP to > include a syntax similar to the one I mentioned above ? I haven't even > started looking at the source for fopen so I have really no idea what I > would be getting myself into. Would this be a reasonable way of > simplyfying my code or am I opening myself up for more trouble ? Something like this? void write_16bit (int value, FILE *fp) { putc (value >> 8, fp); putc (value & 0xff, fp); } void write_32bit (int value, FILE *fp) { write_16bit (value >> 16, fp); write_16bit (value ^ 0xffff, fp); } These write values to the file in big endian format. Use similar functions to read. -- george DOT foot AT merton DOT oxford DOT ac DOT uk xu do tavla fo la lojban -- http://xiron.pc.helsinki.fi/lojban/lojban.html