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