delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/20/16:40:13

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help plz.
Date: Tue, 20 Oct 1998 13:33:44 -0700
Organization: Alcyone Systems
Lines: 39
Message-ID: <362CF3A8.31B252BB@alcyone.com>
References: <362C9048 DOT DFB63546 AT yahoo DOT com>
NNTP-Posting-Host: charmaine.alcyone.com
Mime-Version: 1.0
X-Mailer: Mozilla 3.01 (X11; I; Linux 2.0.34 i686)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

][v][]2. ][) wrote:

> void Load_Level( char level )
> {
>   int i, j;
>   for( i=0; i<MAX_MAP_WIDTH; i++ ) {
>     for( j=0; j<MAX_MAP_HEIGHT; j++ ) {
>       switch( level[i][j] )
>         case 0:
>   // the rest doesn't really matter
> }
	...
> Well, the error message i keep getting is this:
> in the line that says switch( level[i][j] )  : invalid types char[int]
> for array subscript.

The problem is that `level' here is a char, not an array of array of
char.  It should be:

    void LoadLevel(char level[MAX_MAP_WIDTH][MAX_MAP_HEIGHT])
        ...

or

    void LoadLevel(char level[][MAX_MAP_HEIGHT])
        ...

since the function doesn't need to know the dimensions of the first
array.  The array itself, when passed in, must be defined similarly to
the parameter to the first example function above.

-- 
Erik Max Francis / email max AT alcyone DOT com / whois mf303 / icq 16063900 
Alcyone Systems / irc maxxon (efnet) / finger max AT sade DOT alcyone DOT com
  San Jose, CA / languages En, Eo / web http://www.alcyone.com/max/
          USA / icbm 37 20 07 N 121 53 38 W / &tSftDotIotE
             \
            / Every time a friend succeeds, I die a little.
           / Gore Vidal

- Raw text -


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