Can anyone help me? i wanted to split a user input strings into array. seperating them by "," (comma) and will ignore curly braces and spaces. the user must input {abc,def,ghi} (including the curly braces).
the result should be like:
array[0] = abc
array[1] = def
array[2] = ghi
i'm so lost and really confuse splitting string.
here is my code
#include <sstream>
#include "iostream"
using namespace std;
int main(){
string line;
cin >> line;
string arr[4];
int i = 0;
stringstream ssin(line);
while (ssin.good() && i < 4){
ssin >> arr[i];
++i;
}
for(i = 0; i < 4; i++){
cout << arr[i] << endl;
}
}