www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/05/09:52:00

Message-Id: <199807051349.OAA23474@sable.ox.ac.uk>
Comments: Authenticated sender is <mert0407 AT sable DOT ox DOT ac DOT uk>
From: George Foot <george DOT foot AT merton DOT oxford DOT ac DOT uk>
To: Oliver Batchelor <batch AT netaccess DOT co DOT nz>
Date: Sun, 5 Jul 1998 14:44:08 +0000
MIME-Version: 1.0
Subject: Re: Arrays non integer, uncompatible assignments, Bytes !!! Hel
Reply-to: george DOT foot AT merton DOT oxford DOT ac DOT uk
CC: djgpp AT delorie DOT com

On  5 Jul 98 at 4:28, Oliver Batchelor wrote:

> Could anyone tell me what the type is for a byte.

Try "char" or "unsigned char".  Those are both 8-bit; "unsigned char" 
is unsigned, which is probably what you meant.  DJGPP's default char 
is signed.

If you like:

    typedef unsigned char BYTE;

then:

    BYTE xxx;

to declare `xxx' as a byte.

> Also I have an array called   (would be bytes but I cant find how to
> declare them !)
> 
> Int map[100][100] 

Do you mean `int'?  Remember that C is case sensitive.

> BITMAP *img[50]
> 
> Now I want to zero the whole array or assign the whole array to something
> like 10
> 
> for(x=0;x<100;x++) {
> for(y=0;y<100;y++) {
> Map[x,y]=0;
> }}
> It tells me that this is an incompatible assignment !

In C, "x,y" means "execute `x', then execute `y', and take the value 
of `y'".  So "Map[x,y]" is equivalent to "Map[y]", since `x' has no 
side effects.  "Map[y]" is an array, and you can't assign the value 
`0' to an array.

What you meant was probably either:

    Map[x][y] = 0;

or:

    Map[y][x] = 0;

> and later when I go to draw the sprites on the screen I have
> 
> blit(img[map[x,y]], active_page, .......continues...
> 
> It tells me that array subscript is non integer. 

This is the same problem as above.

> (Im sure this worked in turbo C, both things)

I sincerely hope they didn't!  The comma operator is standard C, and 
if turbo C worked as you wrote above then it would fail to compile 
perfectly valid code.

-- 
george DOT foot AT merton DOT oxford DOT ac DOT uk

- Raw text -


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