I would like a Square 2D array that I can access by indexes. Here is my code:
vector<vector<char>> B;
int SIZE;
cin >> SIZE;
for(int i = 0; i < SIZE; i++){
for(int j = 0; j < SIZE; j++){
cin >> B[i][j];
}
Inputs are are in the form:
3
oox
oxo
xoo
So it want a grid of SIZE x Size of arbitrary characters. The characters are not separated by spaces.
However even when I try separating by spaces my code fails after the first character input.
I’ve also tried using push_back(). But I want to be able to access the elements.
For example B[0][2] should give me ‘x’. How can I do this?
Source: Windows Questions C++