0
我想解析一個命令行字符串,在每個空白處考慮字符串之間有引號之間的單詞。我想將2個引號之間的任何內容存儲爲向量中的1個索引。考慮引號之間的爭論
vector<string> words;
stringstream ss(userInput);
string currentWord;
vector<string> startWith;
stringstream sw(userInput);
while (getline(sw, currentWord, ' '))
words.push_back(currentWord);
while (getline(ss, currentWord, '"'))
startWith.push_back(currentWord); //if(currentWord.compare("")){ continue;}
for (int i = 0; i < startWith.size(); i++)
curr
if(currentWord.compare("")){ continue;}
cout << " Index "<< i << ": " << startWith[i] << "\n";
[性病::引用(http://en.cppreference.com/w/cpp/io/manip /引用) – ZDF
@ZDF從C++ 14開始,這在C++ 11中不可用。 – Murphy
@Murphy正確。 – ZDF