Mail Archives: djgpp/1998/08/05/20:30:58
In article <Ex40Ez DOT 4rK AT fcshome DOT stoneham DOT ma DOT us>, 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.
- Raw text -