Date: Thu, 19 Dec 96 01:03:10 GMT From: "Adrian Martin" Encoding: 44 Text Message-Id: <9611198509.AA850988002@ypn.co.uk> To: djgpp AT delorie DOT com Cc: an118 AT chebucto DOT ns DOT ca Subject: RE:NEED HELP reading header for pcx image file >> I have written code that seems to read in the first 128 bytes, >> which is the header for the pcx file. But when I look at it, it's >> gobble-de-gook, you can't read it. I've even tried reading it as a pcx >> structure. All my reads were done on the file opened in binary mode. Once >> I read in the header via binary, it even shows as garbage when I try to >> access individual header elements via my structure member variable after >> reading it into the structure. Can anybody tell me what's wrong? > >Take a look at the PCX code on my page. It's written for DJGPP. > >My guess is that you're missing a "__attribute__ ((packed))" >somewhere... > I've had the same problem, my solutions is :- The place you copied the structure of the PCX header struct from assumed 16 bit INTs whilst DJGPP/GNU C uses 32 bit ints. So just change any variable initialises from:- typedef struct { : : : unsigned int xmax; unsigned int xmin; : // i cannot remember the rest of the structure : }PCX_header,*PCX_header_ptr; TO: typedef struct { : : : unsigned short int xmax; //shorts are 16 bits in DJGPP unsigned short int xmin; //the bit sizes of variable types : ; //can be found in the djsizes.h : : }PCX_header,*PCX_header_ptr; Adrian Martin.