我想输入一个短语并提取短语的每个字符:
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语句中比较指针和整数