-1

let's say I have a vector storing vectors of strings. std::vector<std::vector<std::string>> MyVec = { {}, {} }

I want to use anything equivalent to .push_back(X) such that the vector will now look as following: { {X}, {} }.

Does anyone have an idea for a way to solve this?

bolov
  • 72,283
  • 15
  • 145
  • 224
Itay123
  • 61
  • 1
  • 6
  • 1
    `MyVec[0].push_back(x)` or `MyVec.front().push_back(x)`? – MikeCAT Apr 21 '21 at 12:59
  • @MikeCAT I honestly didn't even think of that, it was too obvious. thank you anyways! – Itay123 Apr 21 '21 at 13:06
  • Please don't include "solved" in the question. The way you indicate you have found a solution is to mark an accepted answer. It's perfectly acceptable to write an answer to your own question, so I suggest you undelete your answer and mark it as accepted. – bolov Apr 21 '21 at 13:17
  • @bolov but I have to wait 2 days to mark it as solved – Itay123 Apr 22 '21 at 13:21
  • Wait 2 days to mark it as solved. – bolov Apr 22 '21 at 14:02
  • @bolov that's literally what I did. until then, I added (solved) in the title. I don't see how I could have acted differently – Itay123 Apr 24 '21 at 08:35

1 Answers1

0

MyVec[0].push_back(x) by @MikeCAT worked.

Itay123
  • 61
  • 1
  • 6