unknow_bunny unknow_bunny - 28 days ago 7
C Question

"value is neither array nor pointer nor vector" in my easy program

please can you help me with my easy program? I am begginer and my english is not good, it hard to understand. :/

PROGRAM:

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');
}
}


PLEASE, can you help me solve this problem? Thank you very much.

Answer

You're missing the type declaration of the argument 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');
    }
}

See C Function with parameter without type indicator still works? for how compilers treat a parameter with no type.