1
我得到的錯誤C編程:下標值既不是數組,也不指針
下標值既不是數組,也不指針
,當我嘗試編譯我的程序。我知道這與變量沒有被聲明有關,但我檢查了一切,並且它似乎被聲明瞭。
static char getValue(LOCATION l)
{
/*return carpark[l.col][l.row]; // Assumes that location is valid. Safe code is
below:
*/
if (isValidLocation(l)) {
return carpark[l.col][l.row]; <<<<<<<< this line
} // returns char if valid (safe)
else {
return '.';
}
對應於這部分代碼在頭
typedef struct
{
/* Rectangular grid of characters representing the position of
all cars in the game. Each car appears precisely once in
the carpark */
char grid[MAXCARPARKSIZE][MAXCARPARKSIZE];
/* The number of rows used in carpark */
int nRows;
/* The number of columns used in carpark */
int nCols;
/* The location of the exit */
LOCATION exit;
} CARPARK;
停車場被宣佈在主PROG有:
CARPARK carpark.
感謝您的幫助。
你什麼錯誤?請在您的問題中粘貼其確切的文字。 – Chriszuma