I'm trying to pass a 2D array into a function with the user's input (asking the user for the number of columns, rows, etc. Here's the code I have. Is there a way to pass the function with said inputs?
#include <iostream> // Input and output
#include <iomanip> // Input manipulator
#include <array>
using namespace std;
int rows;
int columns;
int getTotal(int array[][columns], int, int);
int main()
{
cout << "How many rows would you like to have in your array? " << endl;
cin >> rows;
cout << "How many rows would you like to have in your array? " << endl;
cin >> columns;
int userArray[rows][columns];
getTotal(userArray, rows, columns); // This column will not call the function
return 0;
}
int getTotal(int userArray[][columns], int rows, int columns)
{
// function to add all numbers
}