我有一个称为items
的2D向量,我想用words
填充它。我在创建两个可以将words
元素添加到2D向量的for循环时遇到麻烦。
vector<vector<string>> items;
vector<string> temp;
while(getline(fin, current)) //getting data from file
{
istringstream ss(current); // current is a line that is being broken into words in the following statements
// Traverse through all words
do {
// Read a word
string word;
ss >> word;
// Print the read word
temp.push_back(words);
items.push_back(temp); //this is just an attempt
// While there is more to read
} while (ss);
}
words
是一个字符串变量,其中包含诸如{“ People”“ of”“ it”“ Clement”}
任何事情将不胜感激,请帮助