Mail Archives: djgpp/1998/10/20/16:40:13
][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 -