+ 2

what is wrong here??

#include <stdio.h> void Print(int *(num)[3]) { //printing 5// printf("%d",*(*(num+1))) ; } int main() { int num[2][3]= {{2,3,4},{5,6,7}} ; Print(num) ; } I am practicing on passing multi dimensional arrays to functions. In the program above, I am passing a 2D array to a function Print( ) which simply prints an element in the array. I dont understand what is wrong here . My parameters do seem right cuz the function Print ( ) receives an array of pointers of size 3 which is what i have declared as my parameter. However, my compiler shows an error saying that its an incompatible pointer type. Could anyone explain why that is the case? Thanks!!

25th Nov 2018, 3:18 AM
Yusha Arif
Yusha Arif - avatar
2 odpowiedzi
+ 2
Thanks alot Bennett Post. That must have taken alot of effort to write. I truely appreciate the effort. You really did clarify alot of things for me. Once again, thanks alot!!😊
25th Nov 2018, 6:28 AM
Yusha Arif
Yusha Arif - avatar
+ 1
Bennett Post, i do understand that num[2][3] is considered valid and the program does work but i dont understand why *(num)[3] is considered invalid since both of them do mean the same thing dont they??
25th Nov 2018, 3:44 AM
Yusha Arif
Yusha Arif - avatar