fork download
  1. #include <stdio.h>
  2. #include <stddef.h>
  3. #define LEN 2
  4.  
  5. void foo(int* a[][10], size_t len) {
  6. printf("%s\n", "successfully called foo.");
  7. }
  8.  
  9. int main(void) {
  10.  
  11. // a is an LEN-array of an 10-array of (int *)
  12. int *a[LEN][10] = {{0}};
  13. // but the identifier `a` will decay to be a pointer of type int*[10]
  14.  
  15. // p1 is a pointer to an 10-array of (int *)
  16. int *(*p1)[10] = 0;
  17.  
  18. foo(a, LEN);
  19. foo(&a, LEN);
  20.  
  21. return 0;
  22. }
  23.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:20:13: error: cannot convert ‘int* (*)[2][10]’ to ‘int* (*)[10]’ for argument ‘1’ to ‘void foo(int* (*)[10], size_t)’
  foo(&a, LEN);
             ^
stdout
Standard output is empty