Date: Fri, 14 Mar 1997 09:36:24 -0500 (EST) From: "art s. kagel IFMX x2697" To: Mike Bales Cc: djgpp AT delorie DOT com Subject: Re: Weird problem In-Reply-To: <33287185.892303@news.flash.net> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII DJGPP is a 32 bit compiler so int == long not short. You can read the two values into two shorts with read() or fread(). Alternatively you could read the larger record into a buffer and memcpy the two 16 bit values to shorts. In general, it is good coding practice top explicitely use long and short rather than int since short is guaranteed to be 'at least 16 bits' and long is guaranteed to be 'at least 32 bits' while int is only defined as 'the efficient word size' which varies from one machine and compiler to another. I recommend that you only use int when you do not care about precision but only about speed. I reserve int for loop variables and array indices when I am confident that the range of values it within the precision of any integral datatype that in MIGHT have. Art S. Kagel, kagel AT ts1 DOT bloomberg DOT com On Thu, 13 Mar 1997, 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 >