c - C程序中的"Array subscript is not an integer"

标签 c arrays multidimensional-array char

void imprimirTablero(char *tablero[7][7], int *posicionX, int *posicionY)
{
    int i, j;
    tablero[posicionX][posicionY] = 'R';
    for(i = 0; i < LEN(tablero); i++)
    {
        for(j = 0; j < LEN(tablero[0]); j++)
        {
            printf(tablero[i][j]);
        }
    }
}

此方法更改 positionX、positionY 中的字符并打印新的字符矩阵....请有人帮助我

最佳答案

您正在使用指向整数的指针作为 posicionXposicionY 的数组索引。您需要取消引用这些指针:

tablero[*posicionX][*posicionY] = 'R';

关于c - C程序中的"Array subscript is not an integer",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44103657/

相关文章:

python - 子类化和扩展 numpy.ndarray

java - 如何在转置具有相同变量的数组时修复 ArrayIndexOutOfBounds?

python - 使用字符串定义 Numpy 数组切片

java - 将 javascript 数组传递给 java servlet

arrays - Scala 分配顺序索引数组

javascript - 如何正确迭代这个二维 javascript 数组?

c - 使用 switch - C 后简单程序崩溃

c - 如何交替分割双向链表

c - 为什么当我也打印行数时,行数显示为 0,但当它只是行数时却工作正常

c - 如何更改 128 位数字的字节顺序