c - 我的简单程序中的 "value is neither array nor pointer nor vector"

标签 c arrays pointers vector

请你帮我完成我的简单程序吗?我是初学者,我的英语不好,很难理解。 :/

程序:

void tisk_pole (P);

int main()
{
    char P1[3][3]={{'1','2','3'},{'4','5','6'},{'7','8','9'}};
    tisk_pole(P1);
    return 0;
}

void tisk_pole (P){
    int i, j;

    for (i = 0; i < 3; i++){
        for (j = 0; j < 3; j++)
            printf("%c", P[i][j]);  //HERE IS PROBLEM -> value is neither array nor pointer nor vector
        putchar('\n');
    }
}

请问您能帮我解决这个问题吗?非常感谢。

最佳答案

您缺少参数 P 的类型声明。

void tisk_pole(char P[3][3]) {
    int i, j;

    for (i = 0; i < 3; i++){
        for (j = 0; j < 3; j++)
            printf("%c", P[i][j]); 
        putchar('\n');
    }
}

参见C Function with parameter without type indicator still works?了解编译器如何处理没有类型的参数。

关于c - 我的简单程序中的 "value is neither array nor pointer nor vector",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40533853/

相关文章:

在 VS2010 的 CUDA C 中编译计算能力 2.x

c - C 中的逻辑问题。定义 pthread 上的交互数量

php - 循环内的多维数组合并操作

java - 将 double 转换为 int 数组

Javascript 指针/引用疯狂。有人可以解释一下吗?

c++ - 在终端应用程序中使用 opengl ( 没有 glut/glew )

c - C 中 'free' 的奇怪行为

c++ - C++中的指针是按值传递的吗?

php - 从 mysql 获取数组创建命名 session 数组

c - 打印指针值NULL