delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/13/20:48:09

Date: Thu, 13 Mar 1997 19:35:15 -0600 (CST)
From: Andrew Deren <aderen AT eecs DOT uic DOT edu>
To: Mike Bales <rbales1 AT flash DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: Weird problem
In-Reply-To: <33287185.892303@news.flash.net>
Message-ID: <Pine.SUN.3.95.970313193006.23804A-100000@ernie.eecs.uic.edu>
MIME-Version: 1.0


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?

It is because DJGPP is 32 bit system and ints are 32 bit. Like long in
Turbo C
> 
> 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...
> 
Lets say you have DATAFILE *data = load_datafile("somefile.dat"); in your
program and i and j are short ints, because ints are 4bytes in DJGPP than
to acces first 2 bytes from the data file use:
main()
{
DATAFILE *data = load_datafile("somefile.dat");
short int i, j;
short int *temp;
temp = (short int *)data[MY_DATA].dat;
i = temp[0];
j = temp[1];
}
I hope that helps. I did not test this so I can't be sure if this will
really work.


> Please help.
> 
> Mike
> 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019