Skip to content

Latest commit

 

History

History
9 lines (9 loc) · 401 Bytes

9.39.md

File metadata and controls

9 lines (9 loc) · 401 Bytes
vector<string> svec;
svec.reserve(1024);  // Preallocate memory for 1024 `string`s
string word;
while (cin >> word)  // Read stirngs into `svec`
  svec.push_back(word);
svec.resize(svec.size()+svec.size()/2);
// Reallocate memory, if current capacity is greater then this argument,
// nothing happened, else expand the size to at least the same as the
// argument.