Q:

How To Change Multidimensional Array Size In Program?

Hey I was wondering how I could have settings in-game which would allow the user to set the size of the 'game-board' by changing the array values. Here is the code. I know the code is messy and over the place but it is my first program.
#include "stdafx.h"
#include "iostream"
#include "string"
#include "cstdlib"
#include "ctime"

int xRan;
int choicei = 17;
int choicej = 17;
const int row = 15;
const int col = 16;
int play = 0;

void fill(char Array[row][col]);

int main()
{
    int play = 0;
    char Array[row][col];

    srand((unsigned int)time(0));

    xRan = rand() % 15 + 1;

    if (play == 0)
    {
        std::cout << "1. To Play Treasure Hunt!" << std::endl;
        std::cout << "2. How To Play Treaure Hunt!" << std::endl;
        std::cout << "3. Treaure Hunt Settings! (Comming Soon)\n" << std::endl;
        std::cin >> play;
        std::cout << "-----------------------------------------------------------------------" << std::endl;
    }

    if (play == 2)
    {
        std::cout << "1. Select a row number. Be sure to make it less than or equal to " << row << "!" << std::endl;
        std::cout << "2. Select a column number. Be sure to make it less than or equal to " << col << "!" << std::endl;
        std::cout << "3. If you see the 'X' you have won! If you see the 'O' you lose!" << std::endl;
        std::cout << "-----------------------------------------------------------------------\n" << std::endl;
        std::cin >> play;
    }

    if (play == 3)
    {
        std::cout << "\nComming Soon!" << std::endl;
        std::cout << "-----------------------------------------------------------------------\n" << std::endl;
        std::cin >> play;
    }

    while (choicei > row || choicej > col || choicei < 1 || choicej < 1)
    {
        std::cout << "\nEnter The Row Number Less Than Or Equal To " << row << "!" << std::endl;
        std::cin >> choicei;
        std::cout << std::endl;
        std::cout << "Enter The Column Number Less Than Or Equal To " << col << "!" << std::endl;
        std::cin >> choicej;
        std::cout << "\n-----------------------------------------------------------------------" << std::endl;
        if (choicei > row || choicej > row)
        {
            std::cout << "Make Sure The Row And Column Numbers Are Less Than Or Equal To " << row << "and" << col << "!\n" "---------------------------------------------------------------------- - " << std::endl;
        }
        if (choicei < 1 || choicej < 1)
        {
            std::cout << "Make Sure The Row And Column Numbers Are More Than Or Equal To 1" << "!\n" "-----------------------------------------------------------------------" << std::endl;
        }

    }

    fill(Array);

    std::cout << std::endl;

    for (int i = 0; i < row; i++)
    {
        for (int j = 0; j < col; j++)
        {
            std::cout << Array[i][j] << " ";
        }
        std::cout << std::endl;
    }

    if (xRan > 11)
    {
        std::cout << "\nCongratulations! You Won!\n" << std::endl;
    }
    else
    {
        std::cout << "\nBetter Luck Next Time!\n" << std::endl;
    }

}

void fill(char Array[row][col])
{
    for (int i = 0; i < row; i++)
    {
        for (int j = 0; j < col; j++)
        {
            Array[i][j] = '*';
        }
    }

    if (xRan > 11)
    {
        for (int i = 0; i < 1; i++)
        {
            for (int j = 0; j < col; j++)
            {
                Array[choicei - 1][choicej - 1] = 'X';
            }
        }
    }
    else
    {
        for (int i = 0; i < 1; i++)
        {
            for (int j = 0; j < col; j++)
            {
                Array[choicei - 1][choicej - 1] = 'O';
            }
        }
    }

}

Thank you in advance.

A:

you can't do that with ordinary arrays. you should use dynamic arrays, for example std::vector http://www.cplusplus.com/reference/vector/vector/

