#include<bits/stdc++.h>
using namespace std;
int main() {
string str = "1s2s, 3d2s, 5a4b";
int pos, curPos = 0;
string str1 = "";
while ((pos = str.find(',', curPos)) != string::npos) {
int len = pos - curPos;
str1 += str.substr(curPos, len);
str1 += " ";
curPos = pos + 2; // 다음 ,공백이 아닌 특정 문자가 나오는 지점
}
str1 += str.substr(curPos);
stringstream stream;
stream.str(str1);
string s;
while (stream >> s) {
cout << s << endl;
}
}
결과
1s2s
3d2s
5a4b