Розбити рядок
Розбити по пробілах
int a = line.find(" ");
rez += line.substr(0, a) + line.substr(a + 1, line.length() - a - 1);
Розбити по пробілах 2
string word = "";
for (auto x : str)
{
if (x == ' ')
{
cout << word << endl;
word = "";
}
else
{
word = word + x;
}
}
cout << word << endl;
Розбити по комах і \n
string word = "";
for (auto x : str)
{
if (x == ',' || x == '\n')
{
cout << word << endl;
word = "";
}
else
{
word = word + x;
}
}
cout << word << endl;