From: wagray AT taz DOT dra DOT hmg DOT gb (Walter Gray) Newsgroups: comp.os.msdos.djgpp Subject: Re: How to make DJGPP treat an int as 16-bit in size. Date: 4 Aug 1998 17:25:05 GMT Organization: Defence Research Agency Lines: 24 Message-ID: <6q7g5h$sv4$3@trog.dra.hmg.gb> References: Reply-To: wagray AT taz DOT dra DOT hmg DOT gb NNTP-Posting-Host: taz.dra.hmg.gb To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk In article , fredex AT fcshome DOT stoneham DOT ma DOT us (Fred Smith) writes: :Goh Yong Kwang (s6606555 AT mercury DOT np DOT ac DOT sg) wrote: : :: I have some binary data files that are generated by a 16-bit DOS program :: which treat an int as 2 bytes. : :: Now I want to use DJGPP to write a program to read them but DJGPP thinks :: that an int should be 4 bytes (32-bits) huge. : :: The difference in size of int will cause the program to read the data :: files incorrectly. Is there any easy way to make DJGPP treat int as 2 :: bytes? : :No. : :But you could write the code that reads it to use type 'short' instead, :then once you've got it into the short assign it to an int. : Surely if they are binaries he should be reading them as chars? Walter Disclaimer: My employer is not responsible for this stuff. short int my_short_int_array[N]; fread(my_short_int_array, sizeof(short), N, file); This is good for binary file only. The right method depend on how do You write data.