So, I have a code when I prompt the user to enter a number, I want the size of the 2D array to be changed according to what the user entered, for example:
Enter a number between 1 and 12:
3
The 2D array then will change according to that size to become a 3x3 2D array, I hope I am as clear as I could be, I would really appreciate it if someone can please guide me to a solution, Thank you everyone !!
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
double Atemp = 0;
double Utemp = 0;
double Working = 0;
double Total = 0;
char Answer = 'x';
int Umain;
void displayOverview ();
void playOrQuit();
void promptNumber();
void fillUserArray(char grid[]);
int main(){
    displayOverview();
    playOrQuit();
    promptNumber();
    return 0;
}
void displayOverview(){
   }
void playOrQuit(){
    string playOrNot;
    cout << "If you want to play please press 'p' for play, and 'q' if you wish to quit\n";
    cin >> playOrNot;
    if(playOrNot == "p"){
        cout << "Awesome, lets start playing !!! \n";
    }if(playOrNot == "q"){
        cout << "Alright then, see you soon !!\n";
        exit(0);
    }if(playOrNot != "p" && playOrNot != "q"){
        cout << "Invalid entry !!\n";
        exit(0);
    }
}
void promptNumber(){
    do{
    cout << "Please Enter numbers between 1 and 12: ";
    cin >> Umain;
    if(Umain <= 12){
            for (Utemp = Umain; Utemp > 0; Utemp--){
            cout << "Please enter a number: ";
            cin >> Atemp;
        }
        }else{
            cout << "Not within limit :(\n";
        }
    }while (Answer == 'y');
}
void fillUserGrid (char grid[]){
    for( int row = 0; row < Umain; row++ ) {
        for(int col = 0; col < Umain; col++){
            grid[row][col] = userInput.at( row * Umain + col );
        }
    }
}
void outputUserGrid(char grid[]){
    for (int row = 0; row < Umain; row++){
        for(int col = 0; col < Umain; col++){
              cout << grid[row][col]<<" ";
        }
    cout << endl;
  }
}
 
    