fork(9) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. template<size_t row, size_t col>
  5. void print(int (&a)[row][col])
  6. {
  7. for(size_t i=0; i<row; i++)
  8. {
  9. for(size_t j=0; j<col; j++)
  10. {
  11. cout<<a[i][j]<<" ";
  12. }
  13. cout<<endl;
  14. }
  15. }
  16.  
  17. int main()
  18. {
  19. int r, c;
  20. cin>>r>>c;
  21. int arr[r][c];
  22.  
  23. for(int i=0; i<r; i++)
  24. {
  25. for(int j=0; j<c; j++)
  26. {
  27. cin>>arr[i][j];
  28. }
  29. }
  30. print(arr); //
  31. return 0;
  32. }
  33.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
2 3
1 2 3
4 5 6
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:30:14: error: no matching function for call to ‘print(int [r][c])’
     print(arr); //
              ^
prog.cpp:5:7: note: candidate: template<long unsigned int row, long unsigned int col> void print(int (&)[row][col])
  void print(int (&a)[row][col])
       ^~~~~
prog.cpp:5:7: note:   template argument deduction/substitution failed:
prog.cpp:30:14: note:   variable-sized array type ‘long int’ is not a valid template argument
     print(arr); //
              ^
stdout
Standard output is empty