I'm trying to write a function that reads a 2D array of integers where the user is the one who enters the size of the array (it shouldn't be defined before ) . I tried this but it's not working. I appreciate your help!
line 6 is the declaration of the function
this is my code:
#include <iostream>
using namespace std;
void Fill_table(int mat[][], int s) {
for (int i = 0; i<s; i++) {
for (int j = 0; j<s; j++) {
cout << "mat[" << i << "][" << j << "]:" << endl;
cin >> mat[i][j];
}
}
}
int main()
{
int n;
cout << "Enter the size: ";
cin >> n;
int a[n][n];
Fill_table(a, n);
return 0;
}