Hi. I am tackling the following problem: write the function that builds the multiplication table of arbitrary dimensions. I thought I built the function correctly, but when I call it in main, the variables I declare x and y give me the exceptions "expected for function style cast or type constructor". Is there something I am forgetting? It's really bugging me.
Code:
#include <iostream>
using namespace std;
void create_table(int num_row, int num_col) {
int **table; //initialize pointer to pointer of int
table = new int*[num_row]; //create new space for array of int depending on user input
for (int r=0; r<num_row; r++) {
table[r] = new int[num_col]; //assign pointer to rows of table
}
for ( int r = 0; r < num_row; r++) {
for ( int c = 0; c < num_col; c++) {
**table = r*c;
cout << **table << "/t";
}
}
for (int row = 0; row < num_row; row++) {
delete [] table[row];
}
delete [] table;
}
int main[] {
int y;
int x;
cout << "Please enter number of rows: ";
cin >> y;
cout << "Please enter number of columns: ";
cin >> x;
create_table(y, x);
return 0;
};