Mail Archives: djgpp/1997/03/14/02:29:02
Mike Bales wrote:
>
> This may sound stupid because I am new to DJGPP although have been
> using Turbo C++ for years. Here is some code:
>
> void main(void)
> {
> int x;
>
> // some code here that puts a value into x
>
> printf("X is %d.\n", x);
> }
>
> This is just an example, not the actual code. The number it prints as
> variable X is way about the 32767 limit on ints. (something like a
> million and a half) Why?
>
> Also, I am using an Allegro Grabber datafile. I have a binary file in
> the datafile. How would I put the first 2 and second 2 bytes of the
> binary file into two int variables? I have tried a bunch of ways but
> maybe I am doing something wrong with the pointers. I am not too
> familiar with PM programming...
>
> Please help.
>
> Mike
It is because in Turbo C++, ints are 2 bytes in size. (int = 16bit,
short int = 8bit(?))
In PM, and any other 32bit OS, ints are 4 bytes in size. (int = 32bit =
long int, short int = 16bit)
to fix it, you should try to use a short int for the binary file reader.
and as for the 32767 limit, that's a signed 16bit max. For 32 bits, the
max is 2147483648 for signed ints.
Hope this helps.
- Ray Ratelis
- Raw text -