From: "Balial" Newsgroups: comp.os.msdos.djgpp Subject: Strange fread() behaviour Date: 13 Dec 1996 07:40:26 GMT Organization: Nectar Online Services Lines: 64 Message-ID: <01bbe803$23e24d40$704f12cb@osborne-1> NNTP-Posting-Host: pppc12.nectar.com.au To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Hi, I have a rather strange problem. I have been creating a set of routines and functions that draw graphics and wot not to the screen. To do so I have a screen object, mouse object, image object, text object and mouse object. All these objects are happily acessed and used perfectly by the main() function. My problem occurs when I try to use the image object from any other object (not the main() function). A picture that loads and displays fine from my main() is read incorrectly from my other objects. eg. when I try to load a mouse cursor. I tracked the problem and it seems to be that when I read in the second structure in the image file it reads one of the values as 328 000 or something instead of 0. That would be fine except that my main() can read it OK. Can anyone tell me why this could be??? I also have another problem... I have a structure like this... typedef struct BITMAPFILEHEADER { short Type; /* Two Bytes */ int Size; /* Four Bytes */ short Reserved1; /* Two Bytes */ short Reserved2; /* Two Bytes */ int OffBits; /* Four Bytes */ } ; 2 + 4 + 2 + 2 + 4 = 14 by my calculations... but if I do this printf("Size: %d", sizeof( BITMAPFILEHEADER ) ); if get an output of ... Size: 16 which is not 14!!!! why? If I change the 'short' declarations to short int, it still happens. Does anyone know? Thanx in advance, Balial =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- =-=- Health is the slowest possible rate at which one can die. From the BaLiAl! balial AT mailhost DOT net balial AT resrocket DOT com balial AT nectar DOT com DOT au balial AT ozemail DOT com DOT au http://www.ozemail.com.au/~balial =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- =-=-