Is there a way to initialize all items in a 2d array with console-inputted dimensions to a specified item without looping in C++? For example, say I have two integers, x and y, and a 2d array called grid:
#include <iostream>
int main() {
int x, y;
std::cout << "Enter the dimensions of the array separated by a space: ";
std::cin >> x >> y;
bool grid [x][y] {/*all false*/};
// other code
return 0;
}
Is there any way to initialize every item in grid
in the format above? I tried:
bool grid [x][y] {false};
but that just set the first item to false.