fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. vector<vector<string>> board;
  9. for (int i = 0; i < 3; ++i)
  10. {
  11. vector<string> row;
  12. for (int j = 0; j < 3; ++j)
  13. {
  14. row.push_back("test"); // where value is whatever you want
  15. }
  16. board.push_back(row);
  17. }
  18.  
  19. board[1][1] = "hello";
  20.  
  21. for (auto const& row : board)
  22. {
  23. for (auto const& val : row)
  24. {
  25. cout << val << " ";
  26. }
  27. cout << endl;
  28. }
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
test test test 
test hello test 
test test test