fork download
  1. #include <cstddef>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. template<size_t N, size_t M>
  6. void printPtr( int(&A)[M][N]) {
  7. for(int i=0; i < M; i++){
  8. for(int j=0; j<N; j++) {
  9. cout << A[i][j] << " ";
  10. }
  11. cout << endl;
  12. }
  13. }
  14.  
  15. int main() {
  16.  
  17. int A[][3] = {
  18. { 1, 2, 3 },
  19. { 4, 5, 6 },
  20. { 7, 8, 9 },
  21. { 10, 11, 12 }
  22. };
  23.  
  24. int(*ptrA)[4][3] = &A; // Not a decayed type
  25. printPtr(*ptrA);
  26. printPtr(A);
  27. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
1 2 3 
4 5 6 
7 8 9 
10 11 12 
1 2 3 
4 5 6 
7 8 9 
10 11 12