I can split a given text into a list, but it doesn't work if I want to split a string given by the user.
void removeDupWord(string str)
{
string word = "";
for (auto x : str)
{
if (x == ' ')
{
cout << word << endl;
word = "";
}
else
{
word = word + x;
}
}
cout << word << endl;
}
int main()
{
string ss;
cin >> ss;
ss = "split this";
removeDupWord(ss);
}