delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/06/20:27:38

Sender: nate AT cartsys DOT com
Message-ID: <35A15B33.D219871E@cartsys.com>
Date: Mon, 06 Jul 1998 16:18:11 -0700
From: Nate Eldredge <nate AT cartsys DOT com>
MIME-Version: 1.0
To: Oliver Batchelor <batch AT netaccess DOT co DOT nz>
CC: djgpp AT delorie DOT com
Subject: Re: Arrays non integer, uncompatible assignments, Bytes !!! Help
References: <01bda7cd$fa0e0900$bf0562cb AT dialup DOT voyager DOT co DOT nz>

Oliver Batchelor wrote:
> 
> Could anyone tell me what the type is for a byte.
> 
> BYTE, byte, Byte, b, B  none of these seem to work, BYTE used to work for
> me in turbo c. What is it !!   Very frustrating !!

`unsigned char' is a byte.  Anything like BYTE was a non-portable Turbo
C extension.

> Also I have an array called   (would be bytes but I cant find how to
> declare them !)
> 
> Int map[100][100]
> 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 !

It is.  To index into a 2D array in C, you need to do `Map[x][y]'.  What
you have is the comma operator, which evaluates the first operand and
returns the second.

> 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.

Also true. See above.
 
> (Im sure this worked in turbo C, both things)

Then Turbo C is wrong; or it's a very strange extension.

-- 

Nate Eldredge
nate AT cartsys DOT com


- Raw text -


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