Linked Questions

Popular Questions

I have created a 2d vector that is filled with '0's as it is initialized:

std::vector<std::vector<char>> grid(rows, std::vector<char>(cols, '0'));

however I would like to initialize it as an empty 2d vector with unspecified size:


and then fill it to achieve the same effect as the first statement. I do not think I can use fill() because it has no .begin() or .end() and I have been playing with for loops and push_back to no avail, usually get a segmentation fault error . I feel that what I am trying to do should be possible, and if it is what is the best way to go about doing it? Any help would be greatly appreciated. Thank you.

Related Questions