mercredi 1 juillet 2020

How to make a two dimensional array with user input variables?

I was working in a project, and everything was running smoothly up to this point

int Get_floors()
{
   cout << "Enter how many floors does the stablishment have" << endl;
   int floors;   
   cin >> floors;

   cout << "Enter how many places does each floor have" << endl;
   int places;
   cin >> places;

   constexpr int floorsc = floors;
   constexpr int placesc = places;

   bool lugs[floorsc][placesc];
}

I was trying to make a two dimensional with user-set columns and rows, but it asks for the variable floors and places to be constant.

Aucun commentaire:

Enregistrer un commentaire