I'm very new to programming so I'm sorry if this will sound as a bad question.
My Code:
#include <stdio.h>
void Order(int *waiterList){
printf("Number is %d", *waiterList[0][1]);
}
int main(){
int waiterList[3][3] = {{1,2,3},{4,5,6},{7,8,9}};
Order(&waiterList);
return 0;
}
This code is giving me this error:
pointer.c: In function 'Order':
pointer.c:5:39: error: subscripted value is neither array nor pointer nor vector
printf("Number is %d", *waiterList[0][1]);
pointer.c: In function '`enter code here`main':
pointer.c:13:8: warning: passing argument 1 of 'Order' from incompatible pointer type [-
Wincompatible-pointer-types]
Order(&waiterList);
pointer.c:3:6: note: expected 'int *' but argument is of type 'int (*)[3][3]'
void Order(int *waiterList){
Sorry I've never used array before but our final project is requiring us to use array and I'm finding it difficult to understand the articles I found on google... Hope you could help a student out, It's also my first time posting here because I'm kinda desperate.
&waiterListis not anint *.void Order(int waiterList[3][3]). You need not even worry about "array decay", that part is silently and implicitly handled by the compiler.