提取參數我想輸入一個詞組,並提取短語中的每個字符:使用字符串流
int main()
{
int i = 0;
string line, command;
getline(cin, line); //gets the phrase ex: hi my name is andy
stringstream lineStream(line);
lineStream>>command;
while (command[i]!=" ") //while the character isn't a whitespace
{
cout << command[i]; //print out each character
i++;
}
}
但我得到的錯誤:在while語句
'lineStream >> commmand' * *已經通過提取空格分開的話。 –